views:

33

answers:

1

I've got a suite of about 20 tests that I run on my Development server. I'd like an easy way to switch over to the Alpha server and run those same 20 tests. But I don't want to run them on all servers every time. Typically I'd run the tests on Dev until they are all green, then roll code to Alpha, run tests, etc. Many iterations on Dev, a few on Alpha, then in theory one run on every server up the stack to Release.

The way this is accomplished now is with a variable in the TestFixture. That's all fine -- but requires a rebuild every time I want to change environments. But I saw a menu for Configurations and I thought this would be nifty to use. Add a configuration for each environment, point to that configuration, run tests and they run on the correct server. There's some smelly hardcoding in there: assuming that the name of the environment would have to match up with the name of the target test environment. I can live with that.

First question: is there a better way to do this? Second question: is this even possible? I'm not able to find a way to read those Configurations at the TestFixture level.

+1  A: 

Just use standard .NET configuration files. Appsettings or configuration elements. Any dll (including test) can read them. E.g. mytest.dll.config for mytest.dll, We do this for our "component" or "integration" tests, that have some external dependency, such as a sql server. Test has to know where the server is.

Requisite note on unit tests: be aware you are talking about acceptance or integration tests. Valuable, but expensive to maintain and slow. You should have very few of those, and should have many more unit tests (which would not care where the server is).

Precipitous
I think that amounts to the same thing as changing a string value in my TestFixture. Re the 2nd point: I'm fighting a ton of deployment issues around here, these unit tests are my way of dealing with them until the higher ups realize how much time they waste on these deployment bugs.
jcollum
My shop (most, I think) would consider recompiling a different build - and the tests exist to validate a build. I want exactly the same tests to execute on exactly the same code. If changing it easily is the issue, some MS Build community tasks can update configuration files (then execute NUnit, of course).
Precipitous