Reputation: 6039
I want to order tests that don't share any state.
Example: There are test class CreateFile and DeleteFile.
DeleteFile test uses the same code that CreateFile does. Therefore if CreateFile fails there is no sense to spend time and try to run DeleteFile one. DeleteFile launch won't give any new information. It will end up with the same error.
Let's JUnit skip them.
Upvotes: 0
Views: 91
Reputation: 61705
You're trying to introduce dependencies into your test code. By design, JUnit does not support dependencies between tests. You could try TestNG, which specifically allows dependencies.
Actually, what you're proposing is the optimisation of your tests, not dependencies between tests. You don't want the (delete) test to run because you know it will fail. The result of the create test does not affect the result of the delete test.
A dependency between two tests is more like 'I need test xxx to run before I can run test yyy', because test xxx performs setup for test yyy.
You can use TestNG for both situations, but I prefer to have no dependencies between tests. So all of your setup would be done through @Before or @BeforeClass. Then you can always run a single test in Eclipse or whatever. And in fact for your situation, it is possible that the create file does not work but the delete does, through temporary file system issues.
Upvotes: 1