AnsweredAssumed Answered

How to compare two variables in REST step in CA DEVTEST?

Question asked by ahmmo05 Employee on Jun 2, 2017
Latest reply on Jun 9, 2017 by ahmmo05

Hi,

 

I have a test case in CA DevTest, details are as follows:

1. Rest Step to get initial count, I store this in a filter say {{messageCount}}, say value is 0

2. A JS step to set counter, Java script has following code:

var counter=0;
counter=counter+{{messageCount}};

3. Execute next REST post call which posts a message

4. A JS step to increase the counter which has following code:

counter=counter+1;

5. REST step to get the final count, I store this in a filter saay {{FinalMessageCount}}, say value is 1

I compare using Ensure Result Contains Expression and the regular expression is {{FinalMessageCount}}==counter

Is this valid validation?

 

To meet the expected result I have written one more JS step with following details

 

var num=1;
num=num+{{messageCount}};

if("{{FinalMessageCount}}"==counter)
testExec.setStateValue("executionStatus","Passed");
else
testExec.setStateValue("executionStatus","Failed");

 

 

End result should be 1 and I need to check 1 in the final response

I have attached the script for reference.

 

Please suggest a solution for this.

 

Regards

Irfan

Outcomes