Forum Discussion
Hi Rao,
Thanks for replying. I tried with groovy script. The result is the same, it works when I run in SoapUI, but if I invoke with JAVA runner, it failed.
I think point is why it is working in UI, but with same test project, when invoke from JAVA runner, the input file is not accessiable.
I attached some screenshots and codes. Any hint or guess is welcome.
---
def searchForProductsInputFile = context.expand( '${#Project#searchForProductsInputFile}' )
testRunner.testCase.testSteps['data massage holder'].setPropertyValue("filePath", searchForProductsInputFile)
def filePath = context.expand( '${data massage holder#filePath}' )
log.info filePath
---
Thanks again
Charles
- nmrao10 years agoChampion Level 3I am really sorry to come back, what do you mean by java runner?
- thinker10 years agoOccasional Contributor
Hi Rao,
I tried to trigger this SoapUI test case from jUnit, with SoapUITestCaseRunner.
I added some groovy script into soapui testcase, it still works fine when trigger from SoapUI, but got the following exception when trigger from jUnit, I suspect it is somehow runtime environment related from SoapUI one and my jUnit env.
--------
14:48:41,206 ERROR [SoapUI] An error occurred [Cannot cast object 'com.eviware.soapui.impl.wsdl.teststeps.registry.ProPlaceholderStepFactory$WsdlProPlaceholderTestStep@640c40f9' with class 'com.eviware.soapui.impl.wsdl.teststeps.registry.ProPlaceholderStepFactory$WsdlProPlaceholderTestStep' to class 'com.eviware.soapui.impl.wsdl.teststeps.WsdlDataSourceTestStep'], see error log for details
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.eviware.soapui.impl.wsdl.teststeps.registry.ProPlaceholderStepFactory$WsdlProPlaceholderTestStep@640c40f9' with class 'com.eviware.soapui.impl.wsdl.teststeps.registry.ProPlaceholderStepFactory$WsdlProPlaceholderTestStep' to class 'com.eviware.soapui.impl.wsdl.teststeps.WsdlDataSourceTestStep'
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:392)
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:306)
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:227)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:601)
at Script1.run(Script1.groovy:10)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:92)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:138)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:213)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:139)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:129)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.start(AbstractTestRunner.java:77)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:595)
at com.eviware.soapui.tools.SoapUITestCaseRunner.runTestCase(SoapUITestCaseRunner.java:553)
at com.eviware.soapui.tools.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:385)
at com.eviware.soapui.tools.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:188)
at com.melbourneit.autotest.cucumber.searchForProduct.SearchProductSteps.check_all_case_from_file(SearchProductSteps.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at cucumber.runtime.Utils$1.call(Utils.java:37)
at cucumber.runtime.Timeout.timeout(Timeout.java:13)
at cucumber.runtime.Utils.invoke(Utils.java:31)
at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:38)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:299)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:91)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:93)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:37)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.api.junit.Cucumber.run(Cucumber.java:98)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)------JAVA code (part of it)-
import com.eviware.soapui.tools.SoapUITestCaseRunner;...
@test
public void check_all_case_from_file() throws Exception {
SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
runner.setProjectFile("/Users/charleswu/Documents/soapui_project/searchForProduct/Catalog-int-jbo-101-remote-soapui-project.xml");
runner.setProjectProperties(properties);
runner.setTestSuite("Catalog TestSuite");
runner.setTestCase("cucumber searchForProducts");
runner.run();
}POM config
<dependency>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-pro-maven-plugin</artifactId>
<version>5.1.2</version>
</dependency>In the testcase groovy, I added these new script, which is working fine when trigger from SoapUI. but encounter exception when trigger from jUnit.
---------
Groovy scirpt in SOAP UI
import com.eviware.soapui.impl.wsdl.teststeps.*
def searchForProductsInputFile = context.expand( '${#Project#searchForProductsInputFile}' )
WsdlDataSourceTestStep step = testRunner.testCase.testSteps['price_input']
step.getDataSource().setFileName('/Users/charleswu/Documents/soapui_project/searchForProduct/input/${searchForProductsInputFile}')- thinker10 years agoOccasional Contributor
I figured it out.
Since datasource is pro-related function. SoapUIProTestCaseRunner should be used. That is why the testcase is working in SoapUI, but failed when it is called from jUnit.
import com.eviware.soapui.tools.SoapUITestCaseRunner;
-->
import com.eviware.soapui.SoapUIProTestCaseRunner;
Related Content
- 4 years ago
- 9 years ago
Recent Discussions
- 22 days ago