sgtz
sgtz

Reputation: 9019

How To Start Console Apps Before Running NUnit Test Within One VS Solution?

In VS2010 you can specify multiple startup projects (right-click on Solution & selelct appropriate options in the "Startup Project" area).

That works fine if you hit F5, but for NUnit tests I haven't yet found a way to startup those projects before running the tests. Is there a way?

Constraints:

  1. I don't want to run the console apps from dos, as I want debug support.

  2. I don't want to have a seperate solution open. My Reasoning here is just that there's a little more friction switching between solutions & making sure edits go in the right solution. VS2010 does a good job of checking when files have changed, but, it'll just be easier to have one integrated debug experience that works the same way as when hitting F5.

Currently I'm using NUnit with Resharper 6.

Hopefully there's an option somewhere that I'm missing.

Thanks for taking a look at this.


UPDATE:

So it looks like an unsupported situation at the moment. Presently I'm looking at starting the tests as console applications as well. Probably I'll create way of secifying one test or all tests manually.

It'd be nice to be able to get a report on success/failure even if run outside of the test runner. Is it back to doing this manually?

A SOLUTION

Pedro posted these links in the comments to solution posts:

For these files in *C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0*:

I made these settings changes:

Under <configuration> add:

    <startup>
      <supportedRuntime version="v4.0.30319" />
    </startup>

and under <runtime> add:

    <loadFromRemoteSources enabled="true" />

Upvotes: 4

Views: 2688

Answers (3)

ckittel
ckittel

Reputation: 6646

Since you are using Resharper as your test running, I'm curious if you have tried something along these lines. Set your solution's startup projects to be the console application(s) you want, and press F5. Then, right-click on the test project/file that you are interested in running and then click 'Run Unit Tests.'

It looks like Resharper hides the 'Debug Unit Tests' option while the solution is the running state, but if you are looking to debug the console app side of things, this might work for you (totally untested theory at this point). I would assume you would be out of luck debugging the test side of things though using this method.

And of course this is tied to Resharper's test runner, if you were looking to do this on a continuous integration build system or via the NUnit GUI/Console, this method wouldn't even come close to helping you out.

Upvotes: 1

Pedro
Pedro

Reputation: 12328

In another question, I posted a solution for running the NUnit GUI simply by pressing F5. If you then set the unit tests and console app projects to both run, you should get the desired outcome.

Upvotes: 1

Shaun Hamman
Shaun Hamman

Reputation: 2347

According to this page, NUnit has a [TestFixtureSetUp] attribute that will run once before running any other unit tests. While I haven't used NUnit myself, I would think you should be able to launch any necessary prerequisite programs in a method tagged with this attribute. As the code is executed just like any other, I would think it could be debugged like any other block of code as well.

Upvotes: 1

Related Questions