views:

201

answers:

6

I am using NUnit to test my c# code and have so far been keeping unittests (fast running ones) and integration tests (longer running) seperate and in separate project files. I use nunit for doing both the unittests and the integration tests. I just noticed the category attribute http://www.nunit.org/index.php?p=category&r=2.2 that nunit provides so that tests can be categorized. This begs the question weather I should mix them together and simply use the category attribute to distinguish between them?

A: 

I would keep with whatever method you're currently using. It's more of an opinion thing, and you wouldn't want to have to re-tool your whole testing method.

Alex Fort
it's only an "opinion thing" until the integration tests require special deployment, set-up, and/or tear-down, then it becomes a "necessity thing" ;-)
Steven A. Lowe
I was about to state that either method works, but Steven does have a point. The two types of tests may have different requirements. And two assemblies vs one shouldn't make much difference...
Pedro
+6  A: 

if it is not too difficult to separate them, do so now

unit tests should be run early and often (e.g. every time you change something, before check-in, after check-in), and should complete in a short time-span.

integration tests should be run periodically (daily, for example) but may take significant time and resources to complete

therefore it is best to keep them separate

Steven A. Lowe
+1  A: 

I find that using separate projects for unit test and integration tests tends to create a little too many top level artifacts in the projects. Even though we're TDD and all, I still think the code being developed should be deserving at least half of the top-level of my project structure.

krosenvold
A: 

seperate them if possible, because integration tests normally take much longer than UnitTests. Maybe your project grows and you end up with very much tests, all which take a short amount of time - except the integration tests - and you want to run your UnitTests as often as possible...

Calamitous
A: 

I don't think it really matters that much but separating them sounds like a better idea, since isolation, automation will be so easier. And category feature is nice but not that good from usability point of view.

dr. evil
A: 

The original motivation behind [Category] was to solve the problem you mention. It was also intended to create broader test suites but that is kind of what you are doing.

Do be careful with [Category]. Not all test runners support it the same way the NUnit gui does (or did, I haven't upgraded in a while). In the past some runners would ignore the attribute if it was on the class itself or just ignore it all together. Most seem to work now.

Mike Two