cancel
Showing results for 
Search instead for 
Did you mean: 

Contains assertion passed in SOAPUI tool, but failed executing from java using WsdlTestCaseRunn

prasannav
New Contributor

Contains assertion passed in SOAPUI tool, but failed executing from java using WsdlTestCaseRunn

I have assertion created in SOAPUI tool to verify content in response as given below and it is passing.

 

import groovy.json.JsonSlurper

def responseContent = messageExchange.responseContent
assert(responseContent.contains("queue:"))

 

Now i have exported this project to xml and i am running tests using Java using soapui maven dependency. 

WsdlTestCaseRunner

 SOAPUI test is failing [[Script Assertion] assert(responseContent.contains("queue:")) | | | false  ?%?A@0?S?

 

if noticed responsecontent is not in readable format when executed from java code. Need help on this as i need to run soaupui tests from java

Tags (1)
3 REPLIES 3
HimanshuTayal
Community Hero

Re: Contains assertion passed in SOAPUI tool, but failed executing from java using WsdlTestCaseRunn

Try to change encoding for your Test Request to UTF-8, if still problem exists, please attach any screenshot.

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
prasannav
New Contributor

Re: Contains assertion passed in SOAPUI tool, but failed executing from java using WsdlTestCaseRunn

Hi, i have updated the request with utf-8 as you mentioned. Still it failed when i executed in Java.

 

In SOAUPUI.

SOAUPUI-Screen-1.png

 

SOAUPUI-Screen-2.PNG

 

Note:- i tried with both script assertion and contains assertion. both worked in soapui but not from java.

 

Above project was exported as .xml file and below java code is used to run the tests from .xml file. 

 

PropertiesMap propertiesMap = new PropertiesMap();
// WsdlTestCase testcase = (WsdlTestCase)testSuiteName.gette

WsdlTestCase xTestCase = (WsdlTestCase) testSuite.getTestCaseByName(testCaseName);

WsdlTestCaseRunner testCaseRunner =(WsdlTestCaseRunner)xTestCase.run(propertiesMap,false);


String testCaseRunStatus = null;
testCaseRunStatus =testCaseRunner.getStatus().toString();
List<TestStepResult> testStepResults =testCaseRunner.getResults();

logTestStepResults(testStepResults,reportInstance);
private void logTestStepResults(List<TestStepResult> testStepResults,Reports reportInstance)
{
for(TestStepResult testStepResult : testStepResults)
{
reportInstance.logInfo("Message", Arrays.toString(testStepResult.getMessages()),null);
reportInstance.logInfo("Status",testStepResult.getStatus().toString(),null);
if(testStepResult.getError() != null)
{
reportInstance.logFail("Error",testStepResult.getError().toString(),false,null);
}
else
{
reportInstance.logPass("Error","No Error recorded",false,null);
}
}

 

And this is the result.

 

Actual_Value retrivied from java is junk.PNG

nmrao
Community Hero

Re: Contains assertion passed in SOAPUI tool, but failed executing from java using WsdlTestCaseRunn

New Here?
Join us and watch the welcome video:
Top Kudoed Authors