Download presentation
Presentation is loading. Please wait.
1
13-Jul-15 Test Suites
2
Test classes A unit test is a test of an individual class By convention, we name test classes after the class that is being tested For example, if we have a Machine class, we would have a MachineTest class for testing it This is just a convention—we might have more than one test class for any given class Interfaces have no actual methods to be tested Abstract 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 each
3
Test suites A 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 time Naturally, Eclipse will help you create a test suite Create your unit test classes File New… Other… Java JUnit JUnit Test Suite Click the Next button to choose which unit tests to include in the suite If you add test classes later, you can hand-edit this suite Like the JUnit test classes, it’s just ordinary java
4
Example 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; }
5
Running the test suite Run the test suite just like any other unit test: Run Run As JUnit Test Results are very similar to those for a simple JUnit test
6
The End
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.