How to develop unit tests
This page will be getting more details about Hadoop testing and unit test development guidelines.
Cheat sheet of tests development for JUnit v4
Hadoop has been using JUnit4 for awhile now, however it seems that many new tests are still being developed for JUnit v3. It is partially JUnit's fault because for the false sense of backward compatibility all v3 junit.framework classes are packaged along with v4 classes and it all is called junit-4.5.jar. Speaking of a good release management principles
Here's the short list of traps one need to be aware and not to develop yet another JUnit v3 test case
- YES, new unit tests HAVE to be developed for JUnit v4
DO NOT use junit.framework imports
DO use only org.junit imports
DO NOT extends TestCase (now, you can create your own test class structures if needed!)
DO use @Test annotation to highlight what methods represent your test cases
- Also, any asserts your will be using need to be statically imported either one by one, i.e.
import static org.junit.Assert.assertTrue;
or all of them at once
import static org.junit.Assert.*;
Did you find the above not to be clear enough? Read Quick tutorial right from JUnit website.