Test Suites - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Test Suites

Description:

By convention, we name test classes after the class that is being tested ... Like the JUnit test classes, it's just ordinary java. Example test suite (slightly edited) ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 8
Provided by: cisU
Category:
Tags: after | convention | suites | test | the

less

Transcript and Presenter's Notes

Title: Test Suites


1
Test Suites
  • Recommendations for current assignment

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 CodeMachine class, we
    would have a CodeMachineTest class for testing it
  • Interfaces have no actual methods to be tested
  • Abstract classes may have non-abstract methods
    that can be tested (and abstract ones that cant)
  • If a project has multiple classes, it makes sense
    to have a test class for each

3
Test classes for the current assignment
  • Here are the classes you need
  • SecretCode2 (GUI classnot readily testable)
  • CodeMachine (abstract)
  • SimpleCodeMachine
  • ArrayCodeMachine
  • PigLatinMachine
  • Here are the test classes I recommend
  • CodeMachineTest
  • SimpleCodeMachineTest
  • ArrayCodeMachineTest
  • PigLatinMachineTest

4
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, its just ordinary
    java

5
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(CodeMachineT
est.class) suite.addTestSuite(ArrayCodeMa
chineTest.class) suite.addTestSuite(Simpl
eCodeMachineTest.class)
suite.addTestSuite(PigLatinMachineTest.class)
return suite
6
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

7
The End
Write a Comment
User Comments (0)
About PowerShow.com