【发布时间】:2021-03-17 14:45:01
【问题描述】:
在 VS Code 中使用 C#、Selenium、SpecFlow 和 xUnit 的自动化测试项目仍然存在问题 我正在尝试使用 ITestOutputHelper 输出到日志作为测试进度。
所以我有这门课
using Xunit.Abstractions;
[Binding]
public class Logging
{
private readonly ITestOutputHelper _testOutputHelper;
public Logging(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}
public void WriteOutput(string theMessage)
{
_testOutputHelper.WriteLine(theMessage);
}
}
从这个类中调用
public static class WriteLog
{
static string _logout;
public static void WriteLogData(string logout)
{
_logout = logout;
}
public static void WriteToLog(this Logging logger)
{
logger.WriteOutput(_logout);
}
}
我正在尝试使用以下方法从测试中调用 WriteLog
public static void WriteToReport(string theMessage)
{
WriteLog. WriteLogData(theMessage);
WriteLog. WriteToLog();
}
但WriteLog.WriteToLog(); 出现错误
错误是
There is no argument given that corresponds to the required formal parameter 'logger' of 'WriteLog.WriteToLog(Logging)'
所以我的问题是,如何将日志信息发送到 Logging.WriteOutput?
谁能给点建议?
提前致谢
凯夫
【问题讨论】:
-
我认为您的方法名称有问题。 Logging 类的WriteToLog 扩展方法和其他WriteToLog(string) 方法各不相同。尝试将其中一个重命名为其他名称。
-
@AndreasWillich 指出,这些已经更改,问题仍然存在。
标签: c# selenium xunit specflow