Skip to main content
1-Visitor
October 22, 2019
Solved

Creating Test Session with defined parameters - MultiValue issue

  • October 22, 2019
  • 2 replies
  • 2948 views

Hello,

 

I'm developing software, that is creating test session based on test specification, and i already handled getting data from PTC, but i can't create Test Session using CmdRunner.

 

 

 try
 {
 PTC.Command Cmd = new PTC.Command(PTC.Command.IM, "createissue");
 PTC.MultiValue mv1 = new PTC.MultiValue("=");
 PTC.MultiValue mv2 = new PTC.MultiValue("=");
 PTC.MultiValue mv3 = new PTC.MultiValue("=");
 mv1.add("Summary");
 mv1.add("AutoSessionTest1");
 mv2.add("Project");
 mv2.add("/MySampleProject/Electronics");
 mv3.add("Test Objective");
 mv2.add("473680");
 Cmd.addOption(new PTC.Option("type", "Test Session"));
 Cmd.addOption(new PTC.Option("field", mv1));
 Cmd.addOption(new PTC.Option("field", mv2));
 Cmd.addOption(new PTC.Option("field", mv3));
 PTCResponse.Response R = InputEngine.Run(Cmd);
 MessageBox.Show("Test Session Created");
 }
 catch (Exception exc)
 {
 MessageBox.Show(exc.Message);
 }

 

Do you have an Idea why it won't work?

 

Best regards,

Chris

Best answer by PE_NangaSystems

haven´t used MultiValued for some time now, but I believe you only have to use it that way

 

 Option fieldOption = new Option("field");
 MultiValue multiValue = new MultiValue("=");
 multiValue.add("fieldName");
 multiValue.add("fieldValue");

MultiValue multiValue1 = new MultiValue("=");
multiValue.add("fieldName1");
multiValue.add("fieldValue1");
// Add the MultiValue object to the Option object. fieldOption.add(multiValue);
fieldOption.add(multiValue1);

the integrations builder guide unfortunately has no sampe, this is copied from the javadoc..

 

I personally don´t use multivalue

you can also add the same command option multiple time, e.g.

Command cmd = new Command(Command.IM);
cmd.setCommandName("createissue");
cmd.addOption(new Option("field", "Shared External ID=123456"));

cmd.addOption(new Option("field", "Summary=Summary_123456"));

...

 

if you want to do troubleshooting you can try running the command using CLI, then you should get a proper error message.

you cannot rely on ex.getmessage(), sometimes the ex has a nested one. the builder guide pdf has some good samples

 

Phil

2 replies

5-Regular Member
October 23, 2019

What message are you getting back when it fails?

 

7-Bedrock
October 23, 2019

haven´t used MultiValued for some time now, but I believe you only have to use it that way

 

 Option fieldOption = new Option("field");
 MultiValue multiValue = new MultiValue("=");
 multiValue.add("fieldName");
 multiValue.add("fieldValue");

MultiValue multiValue1 = new MultiValue("=");
multiValue.add("fieldName1");
multiValue.add("fieldValue1");
// Add the MultiValue object to the Option object. fieldOption.add(multiValue);
fieldOption.add(multiValue1);

the integrations builder guide unfortunately has no sampe, this is copied from the javadoc..

 

I personally don´t use multivalue

you can also add the same command option multiple time, e.g.

Command cmd = new Command(Command.IM);
cmd.setCommandName("createissue");
cmd.addOption(new Option("field", "Shared External ID=123456"));

cmd.addOption(new Option("field", "Summary=Summary_123456"));

...

 

if you want to do troubleshooting you can try running the command using CLI, then you should get a proper error message.

you cannot rely on ex.getmessage(), sometimes the ex has a nested one. the builder guide pdf has some good samples

 

Phil

kbi1-VisitorAuthor
1-Visitor
October 28, 2019

It works your way,

 

Thanks a lot!