FeaturesPluginsDocs & SupportCommunityPartners

JUnit Test Specification

Author: Daniel Mladek
Version: 1.0.0
Last update: 28.05.2004
Introduction: This document contains test specifications for JUnit module. You could use this prepared SampleProject or create your one.
Comment: JUnit module is an extension to JUnit framework and serves in NetBeans IDE as a support for creating unit tests of individual classes or whole packages. It generates skeletons of those unit tests and allows to run tests 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 code of JUnit test
Setup: It is supposed that you have created a SampleProject (Desktop->J2SE Application project type) with Main class in it and other 3 more classes: Knizka, Kolo, Vec which contains fields and methods for all access modificators (public, protected, default)

#Test caseDescription
1Create SimpleJUnitTest with all method
1. Select SampleProject|Source Packages|sampleproject|Knizka.java node
2. Invoke Tools|JUnit Tests|Create Tests popup-menu which should open Create Tests dialog
3. Let's have checked on all check-boxes of:
  • Method Accessors
  • Optional Code
  • Optional Comments

4. And click OK button
RESULT: It should generate skeleton of JUnit Test class SampleProject|Test Packages|smapleproject|KnizkaTest.java
2Create SimpleJUnitTest for different modificators
1. Follow steps of previous test case but modify options in dialog. At least try these combinations: All checked, All unchecked, each checked only (for non-methods options check "Public Methods" option too).
RESULT: Check generated sources
3Create JUnit Test on package
1. Select Sample Project|Source Packages|sampleproject package node
2. Invoke Tools|JUnit Tests|Create Tests popup-menu which should open Create Tests dialog
3. Check-on/off randomly check-boxes for Code Generation
4. Finally click OK button
RESULT: It shuld create 4 JUnit TestSuit clasess:
  • KnizkaTest
  • KoloTest
  • MainTest
  • VecTest
under the node/package Test Packages|sampleproject
4Create JUnit Test using expert options
1. Change value of Expert properties in Main-menu: Tools|Options -> Options|Testing|JUnit Module Settings node to something else.
2. Create test and suite classes.
RESULT: Generated source code should slightlt differ from previous code generated by TS 1.3.
Teardown: Remove all generated JUnit Tests generated by you in this Test Suite



Test suite 2: Create Test using New from Tempate

Purpose: This suite should check functionality of creating and generating various code of JUnit test
Setup: It is supposed that you have created a SampleProject (Desktop->J2SE Application project type) with Main class in it and other 3 more classes: Knizka, Kolo, Vec

#Test caseDescription
1Create Empty Test
1. Invoke New File.. Wizard by pressing Ctrl+N or from ToolBar or Main-menu File|New File...
2. Set "Project:" to SampleProject if it is not done already
3. Choose "Categories:" JUnit
4. and select "File Types:" Empy Test
5. and click just enabled Next> button
6. Fill "Class Name:" to KnizkaTest and check-on check-boxes:
    setUp, tearDown, Source Code Hints

RESULT: a JUnit Testing class KnizkaTest has to 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. Follows steps 1-4 of pre-previous test case 2.1, but now choose as "File Types:" Test Suite. And click Next > button.
2. Give "Class Name:", eg. MainTest
3. Check-on check-boxes :
  • setUp, tearDown
  • Source Code Hints left unchecked

RESULT: It should generate MainTest JUnit Test Suite class under the node: SampleProject|Test Packages|sampleproject
Teardown:



Test suite 3: Open Test

Purpose: You're validating if you could open "test" class for current class in Source Packages
Setup: It is supposed that you have created a SampleProject (Desktop->J2SE Application project type) with Main class in it and other 3 more classes: Knizka, Kolo, Vec
And in previous TestSuite you successfuly made "functional" JUnit Tests.

#Test caseDescription
1Open Test for selected class
1. From previous Test Suites you should have had generated JUnit Test classes as a mirror of your real application. So, select node: SampleProject|Source Packages|sampleproject|Kolo.java
2. Invoke on it popup-menu Tools|JUnit Tests|Open Test
RESULT: The JUnit Test Class KoloTest has to open in the source Editor
Teardown:



Test suite 4: Run Test

Purpose: You have to check in this TestSuite if it is possible execute your already created JUnit Tests within the IDE and with which result.
Setup: It is supposed that you have created a SampleProject (Desktop->J2SE Application project type) with Main class in it and other 3 more classes: Knizka, Kolo, Vec
And in previous TestSuite you successfuly made "functional" JUnit Tests.

#Test caseDescription
1Run Tests in Project
1. Select the root SampleProject node in Projects TAB
2. Invoke on it popup-menu and choose Run Test
RESULT: Project should be build (together with JUnit Tests classes) and your test has to be executed
Teardown:

BTW: There's no special action on JUnit Test classes to execute them. In fact it is defined Ant Target deffined in Project build.xml script.

Test suite 5: Accessibility

Purpose: This test suite contains test cases for accessibility.
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.
Teardown:




Generated: Fri May 28 17:11:58 CEST 2004
Companion
Projects:
MySQL Database Server   Open JDK: an Open SourceJDK   GlassFish Community: an Open Source Application Server    Mobile & Embedded Community    Open Solaris   java.net - The Source for Java Technology Collaboration   Virtual Box - full virtualizer  Open ESB - The Open Enterprise Service Bus Powered by