Tuesday, May 11, 2010

Sample Junit Test

import org.junit.* ;
import static org.junit.Assert.* ;

public class ATest {

@Test
public void test_method() {
A a = new A(200,2) ;
assertTrue
(a.getM() == 1.0) ;
}

The marker @Test is called an
annotation in Java. When we later execute JUnit’s test runner it needs
to know which methods in your test class are test methods (e.g. you may
have several helper methods in your test class). The @Test is used to mark that a method is a test method.

No comments:

Post a Comment