









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










What is Test Driven Development
& JUnit?
import junit.framework.TestCase;
public class ShoppingCartTest extends TestCase {
private ShoppingCart cart; private Product book1; // Sets up the test fixture. //Called before every testcase method. protected void setUp() { cart = new ShoppingCart();
public void testEmpty() { cart.empty(); assertEquals(0, cart.getItemCount()); }
...
};
// Another example test suite of tests. suite.addTest(CreditCardTestSuite.suite());
// Add more tests here return suite;
}
//Runs the test suite using the textual runner.
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
junit.textui.TestRunner ShoppingCartTest
junit.swingui.TestRunner ShoppingCartTest