Skip to main content
1-Visitor
October 23, 2018
Solved

Edit Test Step by Java API

  • October 23, 2018
  • 1 reply
  • 1996 views

I've found that It is possible to edit a test step using the CLI with: 

tm editresult --stepVerdict="stepID=216:verdict=Passed" --sessionid=228 78.

 

However when I try an equivalent command using the Java API I get an error:

Could not save modified test result: Invalid step verdict value specified: "stepID=216:verdict=Passed"

 

Can anyone please advise on the correct syntax to use within the Java API to perform this command?

 

I'm using ILM version 12 server.

Best answer by awalsh

I was able to edit the test step verdict with the following code:

 

import java.util.*;
import com.mks.api.*;
import com.mks.api.util.*;
import com.mks.api.response.*;

public class sample {
 public static void main(String[] args) {
 try {
 Command cmd = new Command("tm", "editresult");
 Option testStep = new Option("stepVerdict","stepID=568:verdict=Passed");
 Option sessionID = new Option("sessionID","1638");
 cmd.addOption(testStep);
 cmd.addOption(sessionID);
 cmd.addSelection("572");
 

 IntegrationPointFactory factory = IntegrationPointFactory.getInstance();
 IntegrationPoint ip = factory.createIntegrationPoint("localhost", 7001, 4, 16);
 Session s = ip.createNamedSession("mySession", null, "tester", "password");
 CmdRunner cr = s.createCmdRunner();
 Response r = cr.execute(cmd);

 Result res = r.getResult();
 ResponseUtil.printResult(res, 1, System.out);
 
 } catch (APIException e) {
 ResponseUtil.printAPIException(e, 1, System.out);
 }
 }
}

The output is:

Result:
 Message = Edited test result

1 reply

awalsh5-Regular MemberAnswer
5-Regular Member
October 25, 2018

I was able to edit the test step verdict with the following code:

 

import java.util.*;
import com.mks.api.*;
import com.mks.api.util.*;
import com.mks.api.response.*;

public class sample {
 public static void main(String[] args) {
 try {
 Command cmd = new Command("tm", "editresult");
 Option testStep = new Option("stepVerdict","stepID=568:verdict=Passed");
 Option sessionID = new Option("sessionID","1638");
 cmd.addOption(testStep);
 cmd.addOption(sessionID);
 cmd.addSelection("572");
 

 IntegrationPointFactory factory = IntegrationPointFactory.getInstance();
 IntegrationPoint ip = factory.createIntegrationPoint("localhost", 7001, 4, 16);
 Session s = ip.createNamedSession("mySession", null, "tester", "password");
 CmdRunner cr = s.createCmdRunner();
 Response r = cr.execute(cmd);

 Result res = r.getResult();
 ResponseUtil.printResult(res, 1, System.out);
 
 } catch (APIException e) {
 ResponseUtil.printAPIException(e, 1, System.out);
 }
 }
}

The output is:

Result:
 Message = Edited test result
1-Visitor
October 25, 2018

Thank you very much and I can confirm this works perfectly.