import java.util.*; import junit.framework.*; /** * A recipe straight from the JUnit FAQ * under "How do I write a simple test?" * @author Jim Mahoney (following thousands of others) * @version "0.1" */ public class TestBinarySearch extends TestCase { public TestBinarySearch(String name){ super(name); } public static Test suite(){ return new TestSuite(TestBinarySearch.class); } public static void main(String args[]){ junit.textui.TestRunner.run(suite()); } // create any private variables for the tests here // that multiple testSomeThing()'s use. private BinarySearch bs; public void setUp(){ bs = new BinarySearch(); } // Make as many of these as needed, each named test* public void testThatItsOne(){ // claim that something has a true value. This line succeeds : assertTrue(bs.one() == 1); } public void testThatItsZero(){ // This test will fail. assertTrue(bs.one() == 0); } }