General Discussion

Arbitrary executable as test runner

Started by mausch on 9,520 views

Hi,

Is it possible to set up NCrunch to use an arbitrary executable as test runner?
Concretely, I have a test project that is directly an .exe and runs the tests directly, reporting results to console. It doesn't use NUnit or any other typical test framework. Maybe NCrunch could get back test results through something like NUnit's xml reports?
No idea about how this affects instrumentation though.

Cheers,
Mauricio
Hi Mauircio,

Thanks for posting! It is possible to have NCrunch execute the code within your .exe, though you may need to change the way you are approaching the problem.

If the .exe is launched into its own process (as is the normal behaviour with .exes), NCrunch won't be able to take control of the process and obtain coverage information from the code. NCrunch was also designed with the intention of using Tests as entry points rather than processes themselves.

By far the best way to solve this would be to create a test project that is able to call directly into the code that would be executed by your .exe. Most likely your .exe is launched by using the standard 'public void Main(string[] args)' syntax, and as such it should be very possible for you to call this same method from a test and inject the arguments in order to simulate execution by the O/S. Naturally you would have your choice of a number of different test frameworks for the entry point (NUnit, MSTest, MbUnit, MSpec, Xunit), though there is no need to use any of the advanced features of the framework as I presume that you've written the assertions in your console executable already.

I hope this helps.


Cheers,

Remco

Post a reply

Log in to reply.