Junit Example

From RifidiWiki

Revision as of 00:36, 14 May 2008 by Jmaine (Talk | contribs)

Jump to: navigation, search

Junit 4.x may be tricky at first to build test suites or regular tests, but they are pretty easy to write once one gains a hang of it.

Here is an example of a regular test class.

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

public class Example {
    @BeforeClass
	public static void setUpBeforeClass() throws Exception {
              /* things to do before running tests */
        }

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
              /* things to do after running tests */
        }
        
	@Test
	public void testExample1() {

        }

	@Test
	public void testExample2() {

        }        
   
}
Personal tools