TS 61 MobilityJMUnit

Mobility Pack Test Specification for JUnit Support

Author: Lukas Hasik
Version: 1.1
Lastupdate: 27.3.2008
Introduction: Test specification for JMUnit support in Mobility Pack. The JUnit support enables to user to generate tests for their classes in Mobile project.


Contents


Test suite: Generating test skeletons

Purpose: Try the possibilities of the junit support
Setup: Have JMUnitTestingProject_TS_61_MobilityJMUnit.zip opened in NetBeans

  1. "Create JUnit Tests" on a Java Class
    • Setup: Have a class with methods in Mobile project (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject/classTypes/PublicClass.java)
    1. Invoke the Tools > Create JUnit Tests on the class
    • EXPECTED RESULT: The test skeletons are generated correctly. TestSuite midlet is added to MIDlets list (jad/jar).


  1. "Create JUnit Tests" on a MIDlet Class
    • Setup: Have a MIDlet class in Mobile project (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject/allMIDPfileTypes/Midlet.java)
    1. Invoke the Tools menu on the class
    • EXPECTED RESULT: The menu item Create JUnit Tests is missing.


  1. "Create JUnit Tests" on a package
    • Setup: Have a package with files - classes, properties, midlets, etc. - in Mobile project (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject/allMIDPfileTypes)
    1. Invoke the Tools > Create JUnit Tests on the package
    2. Leave all the checkboxes in Create Tests dialog selected
    • EXPECTED RESULT: The test skeletons are generated only for java classes. The MIDlet classes and other file types are ignored.


  1. "Create JUnit Tests" on a "Source Packages" node
    • Setup: Have a mobile project with packages with files - classes, properties, midlets, etc. (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject)
    1. Invoke the Tools > Create JUnit Tests on the "Source Packages" node
    2. Leave all the checkboxes in Create Tests dialog selected
    • EXPECTED RESULT: The test skeletons are generated only for classes. The MIDlet classes and other file types are ignored.


Test suite: Options of "Create Tests" dialog

Purpose: Try the possibilities of the dialog
Setup: Have JMUnitTestingProject_TS_61_MobilityJMUnit.zip opened in NetBeans

  1. "Create JUnit Tests" only public
    • Setup: Have a mobile project with class with different methods access (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject/allReturnTypes/DifferentAccessLevels.java)
    1. Invoke the Tools > Create JUnit Tests on the "DifferentAccessLevels.java" node
    2. Select only the Public checkbox in Method Access Level area in Create Tests dialog
    • EXPECTED RESULT: The test skeletons are generated only for the public methods.
  2. "Create JUnit Tests" only protected
    • Setup: Have a mobile project with class with different methods access (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject/allReturnTypes/DifferentAccessLevels.java)
    1. Invoke the Tools > Create JUnit Tests on the "DifferentAccessLevels.java" node
    2. Select only the Protected checkbox in Method Access Level area in Create Tests dialog
    • EXPECTED RESULT: The test skeletons are generated only for protected methods.
  3. "Create JUnit Tests" only package private
    • Setup: Have a mobile project with class with different methods access (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject/allReturnTypes/DifferentAccessLevels.java)
    1. Invoke the Tools > Create JUnit Tests on the "DifferentAccessLevels.java" node
    2. Select only the Package Private checkbox in Method Access Level area in Create Tests dialog
    • EXPECTED RESULT: The test skeletons are generated only for package private methods.
  4. "Create JUnit Tests" only package private classes
    • Setup: Have a mobile project with package private classes (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject/classTypes/PackagePrivateClass)
    1. Invoke the Tools > Create JUnit Tests on the "classTypes" node
    2. Select only the Package Private Classes checkbox in Class Types area in Create Tests dialog
    • EXPECTED RESULT: The test skeletons are generated only for package private classes and public classes.
  5. "Create JUnit Tests" only abstract classes
    • Setup: Have a mobile project with abstract classes (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject/classTypes/AbstractClass)
    1. Invoke the Tools > Create JUnit Tests on the "classTypes" node
    2. Select only the Abstract Classes checkbox in Class Types area in Create Tests dialog
    • EXPECTED RESULT: The test skeletons are generated only for abstract classes and public classes.
  6. "Create JUnit Tests" only exception classes
    • Setup: Have a mobile project with exception classes (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject/classTypes/ExceptionClass)
    1. Invoke the Tools > Create JUnit Tests on the "classTypes" node
    2. Select only the Exception Classes checkbox in Class Types area in Create Tests dialog
    • EXPECTED RESULT: The test skeletons are generated for only exception classes and public classes. T
  7. Regenerate tests when new method added
    • Setup: Have a mobile project with a class. Generate test skeleton for this class.
    1. Add new method to the class
    2. Invoke the Tools > Create JUnit Tests for the class again
    • EXPECTED RESULT: The test class is updated with new test method. The skeleton is enhanced with tests for new methods.
  8. Two Methods With Same Name
    1. Generate test for class with methods sameNameMethod, SameNameMethod (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject/samename)
    2. The class is in samename package of the test project
    • EXPECTED RESULT: The test method testSameNameMethod isn't generated/called twice
  9. Two Methods With Same Name And Different Parameters
    • Setup: Have class with methods sameNameDifferentParameters(), sameNameDifferentParameters(int i) (JMUnitTestingProject_TS_61_MobilityJMUnit.zip/JMUnitTestingProject/samename)
    1. Generate test for the class
    • EXPECTED RESULT: The test method testSameNameDifferentParameters() isn't generated/called twice


Test suite: Create Test From New File Wizard

Purpose: Test the newEmptyJ2MEUnitTest template
Setup: Have a mobility project opened in NetBeans

  1. Create Empty J2ME Unit Test
    1. Invoke the New > Others > MIDP > Empty J2ME Unit Test
    2. Specify name and package
    • EXPECTED RESULT: The test skeletons with the name is generated into the package. The JMUnit4CLDC10 library is add in project properties.


Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo