我以这种方式进行测试:
NUnit.ConsoleRunner.Runner.Main(new string[]
{
System.Reflection.Assembly.GetExecutingAssembly().Location,"OpenShop_Firefox.dll",
});
我希望从控制台获取所有文本到一个字符串。什么是最好的方式?
答案 0 :(得分:2)
您需要将Console.Out
设置为您选择的流:
using (StringWriter stringWriter = new StringWriter())
{
Console.SetOut(stringWriter);
NUnit.ConsoleRunner.Runner.Main(new string[]
{
System.Reflection.Assembly.GetExecutingAssembly().Location,
"OpenShop_Firefox.dll"
});
string allConsoleOutput = stringWriter.ToString();
}