Forum Discussion

prasannav's avatar
prasannav
New Contributor
6 years ago

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

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

     

    • prasannav's avatar
      prasannav
      New Contributor

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

       

      In SOAUPUI.

       

       

      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.