It's all about the answers!

Ask a question

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


Manjunath KR (145) | asked Jul 24 '13, 9:46 a.m.
retagged Jul 29 '13, 11:58 a.m. by Ralph Earle (25739)

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!

3 answers



permanent link
Krzysztof Kaźmierczyk (7.4k373103) | answered Jul 24 '13, 10:06 a.m.
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

Comments
Manjunath KR commented Jul 24 '13, 11:34 a.m.

Hi Krzysztof,

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

Thanks.


permanent link
Stephane Leroy (1.4k149) | answered Jul 24 '13, 11:49 a.m.
JAZZ DEVELOPER
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


Comments
Manjunath KR commented Jul 25 '13, 3:48 a.m.

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.


Stephane Leroy commented Jul 25 '13, 3:54 a.m.
JAZZ DEVELOPER

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
Ralph Schoon (63.1k33645) | answered Jul 25 '13, 4:33 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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/

Comments
Manjunath KR commented Jul 25 '13, 5:36 a.m.

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 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.