hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Hadoop Wiki] Update of "HowToDevelopUnitTests" by KonstantinBoudnik
Date Wed, 26 Aug 2009 22:04:35 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Hadoop Wiki" for change notification.

The following page has been changed by KonstantinBoudnik:
http://wiki.apache.org/hadoop/HowToDevelopUnitTests

New page:
= 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 [http://code.google.com/p/t2framework/wiki/JUnitQuickTutorial Quick tutorial] right from
JUnit website.

Mime
View raw message