Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to return exit codes through command line adapter(from Junit test scenarios) to RQM test results

We are using RQM 4.0.3 and command-line adapter to execute Junit test scripts stored in local machine. We are not able to return exit codes from the Junit script to the RQM side.

Sample Junit scenarios we are using are:

Sample Junit script HelloWord.java :
public class HelloWorld {
 public String callMe() {
  return("Hello World");
 }
}

 

Sample java script TestHelloWorld.java that gives call to HelloWorld.java :
Import junit.framework.TestCase;
public class TestHelloWorld extends TestCase {
 public TestHelloWorld(String name) {
   super(name);
  }

public void testSay() {
HelloWorld sampleObj = new HelloWorld();
assertEquals("Hello World!", sampleObj.callMe());
}

public static void main(String[] args) {
junit.textui.TestRunner.run(TestHelloWorld.class);
}

In these scripts, how to return exit codes.

Thanks in Advance!

0 votes



3 answers

Permanent link
Hi Manjunath,
You need to add System.exit(code) if you want to return the code by Java:

fo example:

public static void main(String[] args) {
junit.textui.TestRunner.run(TestHelloWorld.class);
System.exit(2);
}

Please let us know if it helps for you.

Best regards,
Krzysztof Kazmierczyk

1 vote

Comments

Hi Krzysztof,

                 I have tried it but it is not returning that value to RQM test result.

Thanks.


Permanent link
Hi Manjunath,
1) my +1 on Krzysztof's answer.
2) for a clarification on returned codes, you could check http://pic.dhe.ibm.com/infocenter/clmhelp/v4r0m3/index.jsp?topic=%2Fcom.ibm.rational.test.qm.doc%2Ftopics%2Ft_customize_cmd_line.html

Regards,
Stéphane

0 votes

Comments

Hi Stephane,

            Yes I have checked the article and I tried to return values like 41,42,etc., but some how by default I am seeing only 'passed' state.

Thanks.

Hi Manjunath,

then, if you experience a behavior different from what's described in:
https://jazz.net/library/article/809#MapCodes
you may want to contact Rational support to investigate further.

Regards,
Stéphane


Permanent link
There is also an interesting blog that might shed some light: http://sudhakarf.wordpress.com/2013/07/20/executing-a-jmeter-testplan-from-rational-quality-manager/

0 votes

Comments

Hi Ralph,

             I have read that blog. The problem is my batch script(.cmd file) is not getting the return value from script( System.exit(41) ). Because when ever I put an echo statement in batch script like "echo errorlevel=%ERRORLEVEL%", it is not showing 41 but by default it is showing errorlevel=0 in result details.

Thanks.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 1,381

Question asked: Jul 24 '13, 9:46 a.m.

Question was seen: 7,534 times

Last updated: Jul 29 '13, 11:58 a.m.

Confirmation Cancel Confirm