Reputation: 2817
I need to create a integration test that will call a console application. Is there a way to run the console apps inside integration test?
Upvotes: 0
Views: 2623
Reputation: 9679
If you console Application returns some value, you could analyse it in your test, something like:
Process P = Process.Start(path, param);
P.WaitForExit();
int result = P.ExitCode;
Assert.AreEqual(0, result);
path
is path to your console application exe and param
are parameters you want to provide..
Upvotes: 0
Reputation: 9649
There are probably many ways to tackle this issue, however, given the little details, there are two ways which I can come up with
var consoleApp = Process.Start("path/to/your/app.exe");
consoleApp.WaitForExit();
This would be the best way to do it, provided the UnitTestProject has a reference to your ConsoleApp (Project or assembly-reference)
Program.Main();
Upvotes: 2