Junit: splitting integration test and Unit tests.

Posted by jeff porter on Stack Overflow See other posts from Stack Overflow or by jeff porter
Published on 2010-04-09T10:19:14Z Indexed on 2010/04/09 10:23 UTC
Read the original article Hit count: 490

Hello all,

I've inherited a load of Junit test, but these tests (apart from most not working) are a mixture of actual unit test and integration tests (requiring external systems, db etc).

So I'm trying to think of a way to actually separate them out, so that I can run the unit test nice and quickly and the integration tests after that.

The options are..

1: Split them into separate directories.

2: Move to Junit4 and annotate the classes to separate them.

3: Use a file naming convention to tell what a class is , i.e. AdapterATest and 
AdapterAIntergrationTest.

3 has the issue that Eclipse has the option to "Run all tests in the selected project/package or folder". So it would make it very hard to just run the integration tests.

2: runs the risk that developers might start writing integration tests in unit test classes and it just gets messy.

1: Seems like the neatest solution, but my gut says there must be a better solution out there.

So that is my question, how do you lot break apart integration tests and proper unit tests?

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about junit