SakshamArora
12 years agoNew Contributor
Soap UI extension not working
Hi,
I am using free version of soapui. I have tried implementing Listener functionality as described in extending soapui section of the website. But, unfortunately i am not able to achieve the purpose of executing a code once test case(AfterRun function) is executed. The code used is:
package soapui.demo;
import java.util.*;
import com.eviware.soapui.SoapUI;
import com.eviware.soapui.model.support.TestRunListenerAdapter;
import com.eviware.soapui.model.testsuite.TestCaseRunContext;
import com.eviware.soapui.model.testsuite.TestCaseRunner;
import com.eviware.soapui.model.testsuite.TestStepResult;
public class DemoListener extends TestRunListenerAdapter
{
private long startTime;
public void beforeRun( TestCaseRunner testRunner, TestCaseRunContext runContext )
{
startTime = System.nanoTime();
}
public void afterRun( TestCaseRunner testRunner, TestCaseRunContext runContext )
{
List<TestStepResult> results=testRunner.getResults();
Iterator<TestStepResult> resultsIterator = results.iterator();
SoapUI.log("Checking Results::");
//int c=0;
// while( c < results.size() ){
// if( results.get(c).TestStepStatus.getStatus().toString() == "FAILED" )
// {
// String failedStepName=results.get(c).getTestStep().getLabel().toString();
// SoapUI.log("Failed at Step "+failedStepName);
// //String Response=results[c].getTestStep().getPropertyValue("Response").toString();
// String Response=runContext.getProperty(failedStepName,"Response").toString();
// SoapUI.log("Respose for failure: "+Response);
// }
// c++;
// }
while (resultsIterator.hasNext()) {
TestStepResult res=resultsIterator.next();
if (res.getStatus().toString() == "FAILED" ) {
String failedStepName=res.getTestStep().getLabel().toString();
SoapUI.log("Failed at Step "+failedStepName);
String Response=runContext.getProperty(failedStepName,"Response").toString();
SoapUI.log("Respose for failure: "+Response);
}
}
}
}
I have created jar of the classpath and added in ext folder as well. Also, my listeners. xml file is placed in listener folder. Please suggest how can I proceed with that.
I am using free version of soapui. I have tried implementing Listener functionality as described in extending soapui section of the website. But, unfortunately i am not able to achieve the purpose of executing a code once test case(AfterRun function) is executed. The code used is:
package soapui.demo;
import java.util.*;
import com.eviware.soapui.SoapUI;
import com.eviware.soapui.model.support.TestRunListenerAdapter;
import com.eviware.soapui.model.testsuite.TestCaseRunContext;
import com.eviware.soapui.model.testsuite.TestCaseRunner;
import com.eviware.soapui.model.testsuite.TestStepResult;
public class DemoListener extends TestRunListenerAdapter
{
private long startTime;
public void beforeRun( TestCaseRunner testRunner, TestCaseRunContext runContext )
{
startTime = System.nanoTime();
}
public void afterRun( TestCaseRunner testRunner, TestCaseRunContext runContext )
{
List<TestStepResult> results=testRunner.getResults();
Iterator<TestStepResult> resultsIterator = results.iterator();
SoapUI.log("Checking Results::");
//int c=0;
// while( c < results.size() ){
// if( results.get(c).TestStepStatus.getStatus().toString() == "FAILED" )
// {
// String failedStepName=results.get(c).getTestStep().getLabel().toString();
// SoapUI.log("Failed at Step "+failedStepName);
// //String Response=results[c].getTestStep().getPropertyValue("Response").toString();
// String Response=runContext.getProperty(failedStepName,"Response").toString();
// SoapUI.log("Respose for failure: "+Response);
// }
// c++;
// }
while (resultsIterator.hasNext()) {
TestStepResult res=resultsIterator.next();
if (res.getStatus().toString() == "FAILED" ) {
String failedStepName=res.getTestStep().getLabel().toString();
SoapUI.log("Failed at Step "+failedStepName);
String Response=runContext.getProperty(failedStepName,"Response").toString();
SoapUI.log("Respose for failure: "+Response);
}
}
}
}
I have created jar of the classpath and added in ext folder as well. Also, my listeners. xml file is placed in listener folder. Please suggest how can I proceed with that.