Download the following JARs and put them on your test classpath: junit.jar hamcrest-core.jar %java package testexample; import org.junit.Test; import org.junit.Assert.*; import junit.framework.*; public class Testexample { public static void main(String[] args) { new Junittest().testConcatenate(); } } class MyClass { public String concatenate(String a, String b) { return a + b; } } class Junittest extends TestCase { @Test public static void testConcatenate() { MyClass m = new MyClass(); String result = m.concatenate("ab", "cd"); assertEquals("abcd", result); System.out.println("test pass"); // If the two values are equal, nothing happens. // The assertEquals() method returns normally. // If the two values are not equal, // an exception is thrown, and the test method stops executing here. assertEquals("abcdx", result); // Exception thrown } }