JUnit category archives

No side effects in test code

When a TestCase runs, it should either succeed or fail: there should be no side effects. For example, Testcases should not write to the console or to a log file, or save anything to a database. There are two reasons for this.

Write useful JUnit test suites

Structure your JUnit test suites to simplify unit testing — you can easily run all your tests with one command.

Don’t write useless Junit tests

This may seem obvious, but many JUnit tests are written that don’t really test anything useful.
Don’t write tests cases for code that’s too simple to fail on its own: that would be a waste of time. You’re supposed to write tests that test your application code, not the test framework or the compiler.

Close
E-mail It