我有控制器从excel获取测试数据,将它们传递给另一个名为SERVICE_APP项目的项目的属性。
当我使用测试用例SoapUI运行它时,控制器正常运行。但是当我从Project-launch / Testsuite启动时使用commandline / soapUI运行时,我收到错误“null对象上的getProjectByName()”。
16:20:53,896 ERROR [SoapUI] An error occurred [Cannot invoke method getProjectB
Name() on null object], see error log for details
java.lang.NullPointerException: Cannot invoke method getProjectByName() on null
object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:
7)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMeta
lassSite.java:45)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallS
teArray.java:45)
at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.
ava:32)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallS
teArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractC
llSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractC
llSite.java:116)
at Script1.run(Script1.groovy:159)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine
run(SoapUIGroovyScriptEngine.java:100)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(
sdlGroovyScriptTestStep.java:154)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestS
ep(AbstractTestCaseRunner.java:239)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentT
stStep(WsdlTestCaseRunner.java:52)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internal
un(AbstractTestCaseRunner.java:152)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internal
un(AbstractTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(Abstract
estRunner.java:139)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
答案 0 :(得分:0)
当我们从命令行/启动运行器
运行时,我们需要加载项目手册http://forum.soapui.org/viewtopic.php?f=5&t=1449
这是因为从命令行运行时没有Workspace,因此您无法以这种方式访问其他项目。要能够访问另一个项目,您需要手动加载它。这可以使用ProjectFactoryRegistry在groovy脚本中完成。
import com.eviware.soapui.model.project.ProjectFactoryRegistry
import com.eviware.soapui.impl.wsdl.WsdlProjectFactory
def workspace = testRunner.testCase.testSuite.project.workspace
def testProject = (workspace==null) ?
ProjectFactoryRegistry.getProjectFactory(WsdlProjectFactory.WSDL_TYPE).createNew("<path to your project>.xml") :
workspace.getProjectByName("ViewingCardManager_v15B4.0")
if(!testProject.open && workspace!=null) workspace.openProject(testProject)
testProject.properties["mqResponse"].value = "blahblah"
@Siking:感谢您尝试提供解决方案