2

I do test in that way:

NUnit.ConsoleRunner.Runner.Main(new string[]
    {
        System.Reflection.Assembly.GetExecutingAssembly().Location,"OpenShop_Firefox.dll",                   
    });

And i want to get all text from console to one string. What is the best way?

Masoud Mohammadi
  • 1,721
  • 1
  • 23
  • 41
Sowiarz
  • 1,071
  • 2
  • 13
  • 27

1 Answers1

2

You need to set Console.Out to a stream of your choosing:

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();
}
Patrick Quirk
  • 23,334
  • 2
  • 57
  • 88