Showing posts with label Junit. Show all posts
Showing posts with label Junit. Show all posts

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.

Junit Version

JUnit is linked as a JAR at compile-time; the framework resides under packages junit.framework for JUnit 3.8 and earlier and under org.junit for JUnit 4 and later.

currently I am using junit-3.8.2.jar which is installed eclipse plugin.

You can also find out Junit Version in Java by doing the following:



import junit.runner.Version;

System.out.println("JUnit version is: " + Version.id());