【发布时间】:2021-03-16 16:59:25
【问题描述】:
我最近将一个项目从 NUnit 切换到 xUnit,以便可以使用 ITestOutputHelper 输出到日志。
该项目是一个相当标准的布局
功能文件->步骤类->页面类->帮助类。包括在帮助类中,我们也有 hooks.class。我正在使用 xUnit 跑步者。
所以在我的钩子类中我创建了这个
private readonly ScenarioContext _scenarioContext;
private ITestOutputHelper _testOutputHelper;
public Hooks(ScenarioContext scenarioContext, ITestOutputHelper testOutputHelper)
{
_scenarioContext = scenarioContext;
this._testOutputHelper = testOutputHelper;
}
public void WriteOutput(string theMessage)
{
_testOutputHelper.WriteLine(theMessage);
}
现在我的问题是如何从其他类访问 WriteOutput 函数? 还是我把它放在了错误的班级?
【问题讨论】:
-
“其他类”是什么意思?步骤定义? Selenium 页面模型?实用程序类?
-
@GregBurghardt,是的,对不起,应该说得更清楚。页面模型类和实用程序类
标签: c# selenium automated-tests xunit specflow