Skip to search.
altdotnet · Alt Dot.Net Discussions

Group Information

  • Members: 1347
  • Category: Software
  • Founded: Dec 27, 2007
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

  Messages Help
Advanced
Advantages/Disadvantages to putting NUnit tests in same project with   Message List  
Reply Message #1606 of 24622 |
From what I've seen and done, the standard practice for writing NUnit
tests for a project is to create a separate project to contain the
tests. So for example if I have a project "MegaApp.DomainModel", I
would create a corresponding project "MegaApp.DomainModel.Tests" that
would have all the tests for that project. Recently I've been thinking
about putting the tests directly into the "MegaApp.DomainModel"
project in such a way that "Widget.cs" and "WidgetUnitTests.cs" would
be right next to each other in the Solution Explorer.

There are a couple advantages to this approach:

* The nearness of the files will make it easier (and therefore more
likely) that developers will work on the test in tandem with the class
under test (CUT).
* One can make private methods on the CUT into internal methods and
then write tests for them, if need be.
* Will effectively halve the number of projects in the solution (My
current solution has 40+ non test projects), making the solution
explorer a little less unwieldy.
* I'm thinking this will make it easier for devs unfamiliar with NUnit
testing to gain experience with it faster. (I'm currently trying to
introduce the concept to 10+ developers.)

And the only disadvantage I have thought of so far:

* The production assemblies have a reference to NUnit and contain more
types. Slower compilation and load time?

Thinking about it, that disadvantage really isn't that big of a deal
to me. So far I haven't thought of any other disadvantages. I'm
looking for any more advantages/disadvantages for this approach vs the
norm. Thoughts?



Thu Jan 24, 2008 4:15 pm

crowdozer
Offline Offline
Send Email Send Email

Message #1606 of 24622 |
Expand Messages Author Sort by Date

From what I've seen and done, the standard practice for writing NUnit tests for a project is to create a separate project to contain the tests. So for example...
Jim Bolla
crowdozer Offline Send Email
Jan 24, 2008
4:15 pm

... NUnit ... that ... thinking ... would ... class ... NUnit ... You're basing those advantages on the depth of another tool you're using. I.e. VS doesn't...
Peter Ritchie
ritchiep1 Offline Send Email
Jan 24, 2008
4:27 pm

Right. If you ultimately need to test internal code, usually not a good idea in most cases, you could always go down the route of [assembly: ...
Matthew Podwysocki
matthew.podw... Offline Send Email
Jan 24, 2008
4:31 pm

i used to put all my tests in the same assemblies as the SUT, as you mentioned and have slowly but surely moved away from this technique. I think its all about...
cbilson@...
booleanchoice Offline Send Email
Jan 24, 2008
4:50 pm

(continuing...) Also, what about the practice of always having one test fixture per class in the SUT. When working on larger systems, this makes refactoring...
Chris Bilson
booleanchoice Offline Send Email
Jan 24, 2008
5:08 pm

I tend to have several fixtures per class, testing different aspects of it....
Ayende Rahien
Ayende@... Send Email
Jan 24, 2008
6:21 pm

... My fixtures are always coupled with a specification (either of my own thoughts or one drawn up from the requirements/stories). I think it is very much in...
Bill Barry
after_fallout Offline Send Email
Jan 24, 2008
6:52 pm

Hi Chris, Also, what about the practice of always having one test fixture per class in the SUT. When working on larger systems, this makes refactoring really...
Charlie Poole
cpoole98370 Offline Send Email
Jan 25, 2008
1:03 am

I like to separate things. it makes it less "noisy" in the production code and you don't have to worry about shipping tests with your code. it also makes you...
Roy Osherove
royosherove Offline Send Email
Jan 24, 2008
5:11 pm

... If you were worried about not deploying test code you could always surround the unit tests with #if DEBUG ... #endif...
Bill Barry
after_fallout Offline Send Email
Jan 24, 2008
5:21 pm

... I tend to test release code too......
Peter Ritchie
ritchiep1 Offline Send Email
Jan 24, 2008
5:26 pm

... So, #if INCLUDETESTS and add the token to your builds except where they go to production. I don't write any code that is debug only so it is a non issue to...
Bill Barry
after_fallout Offline Send Email
Jan 24, 2008
5:48 pm

Then you're not testing the same assemblies you're deploying. ... always ... they ... is a...
Peter Ritchie
ritchiep1 Offline Send Email
Jan 24, 2008
5:51 pm

Only the unit tests would be surrounded (and note, I don't do this currently, I simply ship with the test code; it is only going to my webservers anyways); I...
Bill Barry
after_fallout Offline Send Email
Jan 24, 2008
6:33 pm

They're still different assemblies... e.g. tests ran and were successful on assembly.dll date: 1/1/2008 1:05 pm size: 102k. Deployed: assembly.dll date:...
Peter Ritchie
ritchiep1 Offline Send Email
Jan 24, 2008
6:48 pm

and how would that be any different than: tests ran and were successful on assembly.dll date: 1/1/2008 1:05 pm size: 102k ILMerge ran: new assembly...
Bill Barry
after_fallout Offline Send Email
Jan 24, 2008
7:04 pm

Why is deploying tests with the production code (in the same assembly) bad? The only thing I have thought of is if you are publishing a library such as Rhino...
Jim Bolla
crowdozer Offline Send Email
Jan 24, 2008
8:49 pm

Test code in production code is just ... not nice at all ... Pollution of the codebase is inevitable unless you are working on such a small system that test...
Casey Charlton
caseycharlton69 Offline Send Email
Jan 24, 2008
9:02 pm

... The project I am currently working on has over 40 non-test projects and represents over 10 man-years of development so far. Before I showed up a few months...
Jim Bolla
crowdozer Offline Send Email
Jan 24, 2008
9:36 pm

Don't rely on putting test code in the SUT for unit-testing buy-in. That's simply the wrong approach. Get buy-in from the team and do unit testing properly....
Peter Ritchie
ritchiep1 Offline Send Email
Jan 24, 2008
9:41 pm

... You have another problem, start breaking it up....
Ayende Rahien
Ayende@... Send Email
Jan 24, 2008
10:13 pm

... I'd like to, but that's not an option... for political reasons. :/...
Jim Bolla
crowdozer Offline Send Email
Jan 24, 2008
10:31 pm

Jim, I hate to disagree with pretty much everyone else, but I see no issue with throwing the tests right along with the assembly. Certainly it is NOT the ...
Jay R. Wren
sillyevar Offline Send Email
Jan 25, 2008
3:04 am

Phrase the question another way ... what is the disadvantage with maintaining your tests in another project? The advantages are large, so I would have to see a...
Casey Charlton
caseycharlton69 Offline Send Email
Jan 25, 2008
3:11 am

Hi Jim, ... In a similar situation, with about 40 non-test projects, I found that the projects fell into natural groupings, with several assemblies forming a...
Charlie Poole
cpoole98370 Offline Send Email
Jan 25, 2008
1:12 am

You don;t have to have one test project per project under test, in fact a few test projects is probably plenty for a few dozen projects. Test projects don't...
Casey Charlton
caseycharlton69 Offline Send Email
Jan 25, 2008
3:08 am

Hey Casey, ... Depends, I would say it's important if you do (or plan to do) Continuous Integration. I want CC.NET to perform developer builds (i.e. soon after...
si
sshnug_si Offline Send Email
Jan 25, 2008
7:41 am

Increased namespace pollution; you can't differentiate a change in a test from a change in production code forcing a build/deploy if a test is changed;...
Peter Ritchie
ritchiep1 Offline Send Email
Jan 24, 2008
9:19 pm

... Can you give an example where a test would change but not the code it's testing? Even if I am just writing tests around legacy code, I'm doing so with the...
Jim Bolla
crowdozer Offline Send Email
Jan 24, 2008
9:46 pm
First  | < Prev  |  Last 
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help