Jazz Library Execute JUnit test scenarios with Rational Quality Manager
Author name

Execute JUnit test scenarios with Rational Quality Manager

Unit testing is the first step towards delivering Quality software. Junit is one of the tools used by developers to perform unit testing activities. This article explains the procedure to manage & execute JUnit test scenarios from Rational Quality manager.

Overview

Rational Quality Manager (RQM) provides features to Plan, Track, Manage, Execute and Report testing related activities in a software project. Testing is a process, in which every member contributes to the overall quality of the deliverables. In general, the development team is responsible to create and execute unit test cases. JUnit is one among several unit testing tools, available in the market. To perform test execution in different tools, RQM provide variety of adapters. These adapters act as a bridge to communicate information between the client system and RQM server. This article primarily focuses on, assisting readers in creation of test assets and initiate JUnit script execution from RQM.


Configure Rational Quality Manager Adapter

1. Rational Quality Manager provides command line adapter to execute tests. In a standard installation, this adapter will be present in C:Program FilesIBMJazzTeamServerserverconfqmadaptersRQMCommandLineAdapter.zip. Extract and Copy RQM command line adapter folder to the client machine where JUnit scripts reside. In this example the script is copied to folder C:RQM AdapterRQMCommandLineAdapter.

2. Create a configuration file (Junitconfig.ini) to connect to RQM server. Execute following command from Command prompt

  C:RQM AdapterRQMCommandLineAdapter> start.bat -repository https://jazz-server:9443/qm -user ADMIN -password ADMIN -adapter RQMAdapter -adapterName Mani-RQMJUnit -projectArea JKE+Banking+%28Quality+Management%29 -configFile Junitconfig.ini 

User will get the following success response

The adapter is now connected
Created Commandline Adapter

Note:

  • Please refer to "readme.txt" present in the RQMCommandLineAdapter folder for additional parameters
  • If you get error message at this stage, check for the input parameters and the Java setting (CLASSPATH, PATH). Following tec note can also be helpful http://www-01.ibm.com/support/docview.wss?uid=swg21625634

3. In the Rational Quality Manager browse to Execution > Adapter Console. Ensure that the adapter is connected.

Widest possible image


 

Creating JUnit Test Script

4. In this example we are going to create & use a basic JUnit script "Hello World"

Here is the sample Java code for HelloWorld.java.

  public class HelloWorld {  	public String customcode() {  		return("RQM Test Hello World");  	}  }

5. Create a JUnit Test Case named TestHelloWorld.java that will test HelloWorld

Here is the sample Java code for TestHelloWorld.java.

  import junit.framework.TestCase;    public class TestHelloWorld extends TestCase {  	public TestHelloWorld(  		String name) {  			super(name);  		}    public void testReturn() {  	HelloWorld hello = new HelloWorld();  	assertEquals("RQM Test Hello World", hello. customcode());  }    public static void main(String[] args) {  	junit.textui.TestRunner.run( TestHelloWorld.class);  }

6. Create a .cmd file to execute the above script. In this example we name the script as Junit_test.cmd and place it in the C:Junit folder

Here is the sample code for Junit_test.cmd.

  set DATASTORE_DIR=C:Documents and SettingsManivannanIBMrationalsdpworkspacejunitprojectbin  set CLASSPATH=C:junitjunit.jar;C:Documents and Settings Manivannan IBMrationalsdpworkspacejunitprojectbin  cd %DATASTORE_DIR%  java org.junit.runner.JUnitCore TestHelloWorld

Creating Test Artifacts in Rational Quality Manager

7. Create a unit test case in Rational Quality Manager

Navigate to Construction > Create Test Case

Create a sample test case as shown below

Widest possible image

Note: The Test Phase data need to be configured the Categories.

8. Create a unit test script in Rational Quality Manager

Navigate to Construction > Create Test Script

Create a sample test script as shown below, ensure to select following data and save the test script

Type: Command Line
Select: Use test resources that are local to a test machine
Select Adapter: Mani-RQMJUnit

9. Provide the location of the .cmd script. In this example, the script is present in the C:Junit folder

– Click on Go button

– Select the script to be executed

– Click on Finish and save the unit test script

10. Associate the test case and the test script. Open Sample JUnit Test Case

– Click on Test Scripts

-Click on Add

– Select the Sample JUnit Test Script

– Click on OK button

11. Create a Test Execution Record to execute Sample JUnit Test Case

– In the Sample JUnit Test Case, click on Test Execution Records

– Click on Generate New Test Execution Record button

– Click on Generate Test Environment tab and select Sample Command Line Adapter

– Click on Next

– Select the command line adapter and click on Next

– Select Sample JUnit Test Case and click on Finish.

– Save the test case.


Execution of Test Case

12: Click on the Run Test Case

– Select appropriate data from the drop down list ( Test Execution Records, Test Environment, Test Script, Machine) as shown in the figure

– Click on OK

 13: During the test execution the Status of the test case will be executed, However when the execution is completed the status changes to Done

– Click on the Close and Show Results

      Click on the Execution Results  tab, user can see that the test had passed

         

          In the same page, Navigate to Result Details section, and click on the *.out file

         

          User can see that the detailed result is displayed in a separate window

         

 14: Modify the JUnit script to a scenario that it returns an error message. Execute the steps 12 and 13, user can find the Result of test execution as Failure and error log attached in the Result Details section.


About the author

Manivannan Sabarajan  is an Advisory IT Specialist for IBM. He has 10+ years of testing tools implementation experience, including work on Rational Functional Tester, Rational Test Manager, Rational Manual Tester and Rational Quality Manager. Manivannan can be contacted at msabarajan@be.ibm.com.

Fri, 16 Aug 2013