// JUnit Test Case // // Author: Steven Cheng Yuen // Modified by Wayne Eberly // // Note: JUnit 4.1 is available. This version makes use of new Java // features, might not work without java 1.5 // // An older version, JUnit 3.82, is still available and can be used // with older versions of Java. // // JUnit is already available for use within the Department of // Computer Science. Of course you will need to install it for // use on your system at home. // // See // // http://www.junit.org // // for additional documentation as well as links to download sites. // import junit.framework.TestCase; public class MyTest extends TestCase { // You can do some initialization here. public MyTest(){ } // Method names that are prefixed with "test" become tests public void testSimple(){ assertTrue(true); } public void testNum(){ assertEquals(1+1, 2); } public void testFail(){ assertEquals("mallard", "duck"); } } // Additional Informaiton: // http://junit.sourceforge.net/doc/testinfected/testing.htm // To compile: // // javac -cp junit.jar:. MyTest.java // To run tests use either of these commands after compiling: // // java -cp junit.jar:. junit.textui.TestRunner MyTest // java -cp junit.jar:. junit.swingui.TestRunner MyTest // If you put junit in your classpath then you don't need -cp junit.jar:.