JUnit Test Specification for NetBeans 5.0
cornercorner
FeaturesPluginsDocs & SupportCommunityPartners

JUnit Test Specification

Author: Max Sauer
Version: 5.0
Last update: 13.9.2005
Introduction: This document contains test specifications for JUnit module. You can use prepared SampleProject or create a new one.
Comment: JUnit module is an extension to JUnit framework and serves in NetBeans IDE as support for creating unit tests of individual classes or whole packages. It generates skeletons of those unit tests and allows to run tests directly from tested classes or packages.

Table of Contents

Test suite 1: Create Test from popup-menu

Purpose: This suite should check functionality of generating various JUnit test code.
Setup: It is supposed that you have created/opened a SampleProject with Main class and three other classes: Knizka, Kolo, Vec which contain fields and methods for all access modificators (public, protected, default)

#Test caseDescription
1Create SimpleJUnitTest with all methods
Setup:Open SampleProject, focus Projects TAB.
  1. Select SampleProject|Source Packages|sampleproject|Knizka.java node
  2. Invoke Tools|Create JUnit Tests from popup-menu -- this should open Create Tests dialog
  3. Check all aviable check-boxes in:
    • Method Accessors
    • Optional Code
    • Optional Comments
  4. Click OK
Teardown: Delete created SampleProject|Test Packages|smapleproject|KnizkaTest.java
RESULT:It should generate skeleton of JUnit Test class SampleProject|Test Packages|smapleproject|KnizkaTest.java
2Create SimpleJUnitTest for different modificators
  1. Follow the steps of previous test case, but modify dialog's options. Try different checkbox combinations.
RESULT:Check generated sources
3Create JUnit Test on package
Setup:Delete all previously created JUnit TestSuites
  1. Select Sample Project|Source Packages|sampleproject package node
  2. Invoke Tools|Create JUnit Tests (Ctrl+Alt-J) from popup-menu. This should open Create Tests dialog.
  3. Check check-boxes for Code Generation randomly.
  4. Click OK
RESULT:Multiple JUnit TestSuit clasess should be created under the node/package Test Packages|sampleproject
4Create JUnit Test using expert options
Setup:Remove generated KnizkaTest.java
  1. Change value of Expert properties in: Tools|Options -> Classic View -> Options|Testing|JUnit Module Settings node to something else.
  2. Create test and suite classes.
RESULT:Generated source code should slightly differ from previous code generated by TS 1.3.
Teardown: Remove all generated JUnit Tests.

Test suite 2: Create Test using New from Tempate

Purpose: This suite should check functionality of creating and generating various JUnit test code
Setup: It is supposed that you have created a SampleProject with Main class and 3 more classes in it: Knizka, Kolo, Vec

#Test caseDescription
1Create Empty Test
  1. Invoke New File.. Wizard by pressing Ctrl+N or from ToolBar
  2. Set "Project:" to SampleProject if it is not done already
  3. Choose "Categories:" JUnit
  4. and select "File Types:" Empy Test
  5. Next> button should be enabled now. Press it.
  6. Fill KnizkaTest in "Class Name:" and check check-boxes:
      setUp, tearDown, Source Code Hints
RESULT:a JUnit class KnizkaTest should be created under the node: SampleProject|Test Packages|sampleproject and opened in source editor.
2Create Test for Existing Class
  1. Follow steps 1-4 of previous test case, but choose Test for Existing Class as a "File Types:" And click Next > button
  2. Click Browse... button and navigate to "Class to Test:" or just type its name Kolo into the text-field
  3. Check-on/off some of the Method Accessors, Optional Code generation, Optional Comments
  4. Click just enabled Finish button
RESULT:It should create KoloTest class under SampleProject|Test Packages|sampleproject node and open it in the source Editor.
3Create Test Suite
  1. Create new TestSuite via the 'New File...' dialog. (Ctrl-N)
  2. Fill in "Class Name:", eg. MainTest
  3. Check following check-boxes :
    • setUp, tearDown
    Leave Source Code Hints unchecked
RESULT:MainTest JUnit Test Suite class should be generated inside: SampleProject|Test Packages|sampleproject

Test suite 3: Open Test

Purpose: To test opening of appropriate JUnit tests.
Setup: It is supposed that you have created/opened a SampleProject with Main class and three other classes in it: Knizka, Kolo, Vec
, with "functional" JUnit Tests created.

#Test caseDescription
1Open Test for selected class
Setup:Close all opened files in the Editor
  1. From previous Test Suites, you should have had generated JUnit Test classes as a mirror of your real application. Select node: SampleProject|Source Packages|sampleproject|Kolo.java
  2. Invoke Go To|Test (Ctrl+Alt-G)
RESULT:The JUnit Test Class KoloTest should be opened and focused in the Editor.

Test suite 4: Run Test

Purpose: Testing of 'Test Project' JUnit feature.
Setup: It is supposed that you have created/opened a SampleProject with Main class and 3 other classes in it : Knizka, Kolo, Vec
with "functional" JUnit Tests.

#Test caseDescription
1Run Tests in Project
  1. Select the SampleProject's root node in Projects tab.
  2. Choose Test Project from its pop-up menu (Alt-F6)
RESULT:Project should be build (together with JUnit Tests classes) and test should be executed. Results should be displayed in JUnit Test Results window and also printed in the Output Window. The 'Show All Resaults' button should be disabled.
2JUnit Test Results I
Setup:Open prepared Test Project.
  1. Test the project (Alt-F6).
RESULT:The result should look like this:

All 'Failed' nodes should be expanded. Information about passed/failed test number should be displayed.
3JUnit Test Results II
Setup:This usecase continues from previous one.
  1. Double click 'at junit_test_results.obsah.nactiFile(obsah.32)' node.
  2. Try to switch between 'Statistics' and 'Output'.
RESULT:'obsah.java' should be opened in the editor, with carret placed on line 32. 'Output' should show raw JUnit output, contining two sections:
  • Standard Output:
  • Error Output:
4JUnit Test Results III
Setup:This usecase continues from previous one.
  1. Change permissions of 'd.txt' file to '644'.
  2. Test the project once again.
RESULT:Only a message should be displayed:
'All 3 tests passed. Information about passed test is not displayed'
5JUnit Test Results -- Comparsion
Setup:This usecase continues from previous one.
  1. Open NewClassTest.java
  2. On line 56, change the value of expResult variable to 4.
  3. Test the project once again (Alt-F6).
RESULT: The result should look like this:

BTW: JUnit test are executed by an Ant Target defined in Project's build.xml script.

Test suite 5: Accessibility

Purpose: This test suite contains accessibility test cases.
Setup: Download a11y.jar and prepare your environment as this document instructs you.

#Test caseDescription
1Check accessibility
  1. Invoke all JUnit dialogs which are accessible from various places, eg. Popup-menu on a file/package, via Main-menu, etc.
  2. Check dialog for accessibility.
  3. Check all dialogs using previous actions.
RESULT:There should be no A11Y bugs. See: A11Y homepage, JUnit module dialogs list.

Generated: 2005 09 13 03:32
Companion
Projects:
MySQL Database Server   GlassFish Community: an Open Source Application Server   Open Solaris  Open JDK: an Open SourceJDK   Mobile & Embedded Community     Sponsored by 
Sponsored by Sun Microsystems