2014-03-31 4 views
2

현재 SoapUI 프로젝트의 많은 코드를 복사하여 붙여 넣기하고 있으며, 대부분의 코드를 수행 할 수있는 일종의 도우미 함수 라이브러리가 있다고 생각합니다. 작업.재사용 가능한 방법의 라이브러리를 정의하는 SoapUI

그래서이 테스트 스위트가 있으며 코드 자체는이 테스트 스위트의 Groovy Script 테스트 단계에있다. 아이디어는 내가 가지고있는 컨텍스트에서 내 도우미 메서드를 사용할 수 있도록 만드는 것입니다 (REST 테스트 요청 단계).

괜찮 으면 모든 것을 인스턴스화하지만 문제는 내가 run(testRunner, context)을 호출 할 때 testRunner 속성에 액세스 할 수 없다는 것입니다. 나는 이것이 이것이 어떻게 일어 났는지에 관해 뭔가를 읽었습니다.

누구든지이 문제를 해결할 방법을 알고 계십니까?

+0

가능한 중복 (http://stackoverflow.com/questions/18075187/script-library-using-groovy-soapui) – olyv

+1

이 영업 이익으로 중복이 요구되지 아니 스크립트 라이브러리를 만드는 방법보다는 테스트 라이브러리가 존재하지 않는 testRunner 객체에 액세스하는 방법을 설명합니다. 스크립트 라이브러리에 액세스하려면 testRunner 객체가 필요합니다. –

답변

2

스크립트 라이브러리와 동일한 방법을 사용하고 있습니다. 내가 케리 도안에 의해 설명 된 방법을 사용하여 http://www.doan.me/script-library-in-soapui-free.aspx

내가 프로젝트로드 스크립트에서 내가 testRunner 개체에 대한 액세스 권한이 없기 때문에 나는이 컨텍스트에 대한 액세스 권한이 없었습니다 객체 나는 그것도 만들어야했습니다.

아래 코드를 확인하십시오.

import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner 
import com.eviware.soapui.support.types.StringToObjectMap 
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext 

//to create the testRunner object I need a testCase object and a new StringToObjectMap 
//I initially used the test case in the script library but as i needed the 
//testRunner object to the test case being executed so i created the object to 
//the test case being executed. 
//I did not want to worry about test suite or test case names so i used their index 
//assuming that there will be at least one test suite and at least one test case when 
//this script is run 
testCase = project.getTestSuiteAt(0).getTestCaseAt(0) 
tcRunner = new WsdlTestCaseRunner(testCase, new StringToObjectMap()); 

//A context is essentially a WsdlTestRunContext object and as you can see below all i 
//have done to create that is pass it a test step object which was obtained by using index 
//rather than name. 
tStep = testCase.getTestStepAt(0) 
tcContext = new WsdlTestRunContext(tStep) 

//my script library is in a seperate project called `Script Library` and all the 
//groovy scripts are in a test suite called `Script Library` 
scripts = project.workspace.projects["Script Library"].testSuites["Script Library"]; 
scripts.testCases["Scripts"].testSteps["runTest"].run(tcRunner, tcContext); 
[Groovy를 사용하여 스크립트 라이브러리 - SOAPUI을]의
+0

고마워, 매력처럼 일 했어! – joakimnorberg

+0

@Abhishek Asthana 덕분에 도움이되었습니다. 테스트 케이스에서 스크립트의 단정에'tcRunner'를 만들었습니다. 나중에'tcRunner'가 다른 어떤 테스트 케이스에서도 유효하지 않다는 것을 깨달았습니다. 어떤 아이디어, 우리는 어떻게'tcRunner '의 생성을 모듈화 할 수 있습니까? 제공 한 링크를 사용하여, 스크립트 어설 션'context.searchChange.search ("value1", "value2", tcRunner)'에서 이와 같이 tcRunner를 전달합니다. 'search'는'tcRunner'를 이용하는 테스트 라이브러리의 메소드입니다. – user1207289

+0

이 작업을한지 오래되었습니다. 어설 션 단계 대신 테스트 사례의 상위 계층에서 tcRunner 개체를 만들어보십시오. 당신이 해결하려고하는 실제 문제는 무엇입니까? 문제와 관련된 동일한 문제에 대한 해결책을 찾는데 도움이되므로 문제에 대한 별도의 질문을 작성할 수 있다면 좋을 것입니다. –