Test SuitesTest classesTest suitesExample test suite (slightly edited)Running the test suiteThe EndTest SuitesTest classesA unit test is a test of an individual classBy convention, we name test classes after the class that is being testedFor example, if we have a Machine class, we would have a MachineTest class for testing itThis is just a convention—we might have more than one test class for any given classInterfaces have no actual methods to be testedAbstract classes may have non-abstract methods that can be tested (and abstract ones that can’t)If a project has multiple classes, it makes sense to have a test class for eachTest suitesA test suite is a class that contains calls to unit test classes (and sometimes other test suites)This is sometimes more convenient than running your unit tests one at a timeNaturally, Eclipse will help you create a test suiteCreate your unit test classesFile New… Other… Java JUnit JUnit Test SuiteClick the Next button to choose which unit tests to include in the suiteIf you add test classes later, you can hand-edit this suiteLike the JUnit test classes, it’s just ordinary javaExample test suite (slightly edited)import junit.framework.Test;import junit.framework.TestSuite;public class AllTests { public static Test suite() { TestSuite suite = new TestSuite("Test for default package"); suite.addTestSuite(CodeMachineTest.class); suite.addTestSuite(ArrayCodeMachineTest.class); suite.addTestSuite(SimpleCodeMachineTest.class); return suite; }}Running the test suiteRun the test suite just like any other unit test:Run Run As JUnit TestResults are very similar to those for a simple JUnit testThe
View Full Document