Reputation: 9785
So what are the objectives here:
Test Isolation means , test code is not accessible with the source, as his can cause security issues, and induce vulnerabilities.
We can Extend and Generalize Test Frameworks beyond just testing the particular source.
We can do refactoring and improvement regardless of Source Changes
Because of isolation we can try running the same test framework against various branches of source code
Performance problems with test code , run time , or overflows do not directly affect test runs, as we can easily revert to the version of the test framework that was performing well.
Questions:
Should the test code and source code be in the same branch ? How would we set that up ? how would that work with lets say subversion, what would be the pros and cons ?
Upvotes: 0
Views: 127
Reputation: 29649
The question is a little imprecise - I'm assuming your question refers to unit testing code, and not acceptance tests, performance tests etc.
The first thing to consider is that there is a tight coupling between test code and the code under test. You need to manage that dependency; how you manage it depends largely on your development strategy. If you use branches to separate features or releases, I'd put the test code for that branch in the same branch - you can't expect it to work on code from another branch. Adding a separate branch for test code makes things more complex, without necessarily adding any benefit.
Secondly - hopefully obviously - you need to manage the dependencies. Your test code depends on the code under test; the code under test should not depend on the test code. Using tools like JDepend or NDepend allows you to monitor these dependencies. It's usually a good idea to explicitly manage the dependencies from the test code - if you find all of your tests depend on a single class in the test under code, that dependency can break every test if something goes wrong.
Now, to answer your specific questions, I'm going to assume you have a branch for (major) features in SVN, and that you've set up a standard project structure, along the lines
\src
\app
\test
The application code lives in the "app" folder; the test code in the "test" directory.
In this case, your SVN might be:
\trunk
\app
\com.me.app.views
\com.me.app.models
\com.me.app.controllers
\test
\com.me.app.tests.views
\com.me.app.tests.models
\com.me.app.tests.controllers
\branches
\feature1
\app
\com.me.app.views
\com.me.app.models
\com.me.app.controllers
\test
\com.me.app.tests.views
\com.me.app.tests.models
\com.me.app.tests.controllers
\feature2
\app
\com.me.app.views
\com.me.app.models
\com.me.app.controllers
\test
\com.me.app.tests.views
\com.me.app.tests.models
\com.me.app.tests.controllers
Upvotes: 1