< p>I am trying to set up a test that calls a console application with specific parameters, and compare the actual output with what I expect, and then execute my usual Assert statement to pass/fail the test appropriately.
The best way I can think of is to execute the app exe using System.Diagnostics.Process in a unit test. This works. I can read the output and everything is fine.
The problem I have is When I want to set a breakpoint in the console application code, I can do some debugging. Since Process starts the console application, Visual Studio does not monitor the console application, so it does not break. There is nothing like “Waiting for a request from an external application” is more like a web application, I understand why, but this is basically what I am looking for.
So my question is, is there a way to set it in Visual Studio These unit tests, where can I still debug console applications? The only solution I can think of is to set Start Action on the console application to start an external program that will call MSTest.exe and run the corresponding unit test in this way. But it seems to be a problem, I I just thought wrong, there is actually a more obvious solution.
class Program
{
static void Main(string[ ] args)
{
Foo foo = new Foo(args);
}
}
After that, you can easily write for your Foo class Unit testing.
I have a test project in Visual Studio, and I want to use it to test my console application (in the same solution). < p>
I am trying to set up a test that calls a console application with specific parameters, and compare the actual output with what I expect, and then execute my usual Assert statement to pass/fail the test appropriately .
The best way I can think of is to use System.Diagnostics.Process to execute the app exe in a unit test. This works. I can read the output and everything is fine.
So my question is, there is There is no way to set up these unit tests in Visual Studio, where I can still debug console applications? The only solution I can think of is to set Start Action on the console application to start an external program that will call MSTest.exe and run the corresponding unit test in this way. But it seems to be a problem, I I just thought wrong, there is actually a more obvious solution.
Make the console application as streamlined as possible and move all business logic to the domain Class. For example.
class Program
{
static void Main(string[] args)
{
Foo foo = new Foo(args);
}
}
After that, you can easily write unit tests for your Foo class.
< p>