Difference between revisions of "Junit Example"

From RifidiWiki

Jump to: navigation, search
(New page: category:developerDoc 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.)
 
Line 1: Line 1:
 
[[category:developerDoc]]
 
[[category:developerDoc]]
 
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.
 
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.
 +
<pre><nowiki>
 +
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() {
 +
 +
        }       
 +
 
 +
}
 +
</nowiki></pre>

Revision as of 00:36, 14 May 2008

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