sis.util.TestUtil


 package sis.util; import junit.framework.*; import java.io.*; public class TestUtil {    public static void assertGone(String... filenames) {       for (String filename: filenames)          Assert.assertFalse(new File(filename).exists());    }    public static void delete(String filename) {       File file = new File(filename);       if (file.exists())          Assert.assertTrue(file.delete());    } } 

Only tests use code in the TestUtil class. Since TestUtil does not extend from junit.framework.TestCase, it does not have instance access to any assert methods. However, the class junit.framework.Assert defines the assert methods as class methods, allowing you to access them anywhere.

Other things you will need to do:

  • Make the GradingStrategy implementation types and Student serializable.

  • Add an id field and associated getter/setter methods to the Student class.

  • Update the AllTests suite classes.[4]

    [4] Having to remember to add the classes is asking for trouble. In Lesson 12, you'll learn how to use Java's reflections capabilities to dynamically build test suites.



Agile Java. Crafting Code with Test-Driven Development
Agile Javaв„ў: Crafting Code with Test-Driven Development
ISBN: 0131482394
EAN: 2147483647
Year: 2003
Pages: 391
Authors: Jeff Langr

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net