코드로 soapUI 테스트를 실행하는 방법을 찾았습니다.
는 작은 설명 :
첫째 - 나는 pom.xml 파일 대신에 직접 포함 .JAR하는 받는다는 프로젝트와 추가 종속성을 만들었습니다. SoapUI 테스트는 다음 종속성을 추가 할 필요했다 경우 : - :
<dependency>
<groupId>net.java.dev.jgoodies</groupId>
<artifactId>looks</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>net.sf.squirrel-sql.thirdparty-non-maven</groupId>
<artifactId>com-fifesoft-rsyntaxtextarea</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.karaf.eik.plugins</groupId>
<artifactId>org.apache.commons.collections</artifactId>
<version>3.2.1</version>
</dependency>
둘째
<dependency>
<groupId>com.github.redfish4ktc.soapui</groupId>
<artifactId>maven-soapui-extension-plugin</artifactId>
<version>4.6.4.0</version>
</dependency>
을 내가 예외를
java.lang.NoSuchMethodError
필요한 종속성을 가지고 있기 때문에 나는 또한 약간의 종속성을 추가
환경을 준비한 후 코드를 작성할 수있었습니다. Java로 지정된 soapUI 프로젝트에서 모든 테스트 스위트와 테스트 케이스를 실행할 수있는 코드 예제를 보여줍니다.
// method for running all Test Suites and test cases in the project
public static void getTestSuite() throws Exception {
String suiteName = "";
String reportStr = "";
// variables for getting duration
long startTime = 0;
long duration = 0;
TestRunner runner = null;
List<TestSuite> suiteList = new ArrayList<TestSuite>();
List<TestCase> caseList = new ArrayList<TestCase>();
SoapUI.setSoapUICore(new StandaloneSoapUICore(true));
// specified soapUI project
WsdlProject project = new WsdlProject("your-soapui-project.xml");
// get a list of all test suites on the project
suiteList = project.getTestSuiteList();
// you can use for each loop
for(int i = 0; i < suiteList.size(); i++){
// get name of the "i" element in the list of a test suites
suiteName = suiteList.get(i).getName();
reportStr = reportStr + "\nTest Suite: " + suiteName;
// get a list of all test cases on the "i"-test suite
caseList = suiteList.get(i).getTestCaseList();
for(int k = 0; k < caseList.size(); k++){
startTime = System.currentTimeMillis();
// run "k"-test case in the "i"-test suite
runner = project.getTestSuiteByName(suiteName).getTestCaseByName(caseList.get(k).getName()).run(new PropertiesMap(), false);
duration = System.currentTimeMillis() - startTime;
reportStr = reportStr + "\n\tTestCase: " + caseList.get(k).getName() + "\tStatus: " + runner.getStatus() + "\tReason: " + runner.getReason() + "\tDuration: " + duration;
}
}
// string of the results
System.out.println(reportStr);
}
출력 :
Test Suite: TS_ONE
TestCase: TC_ONE Status: FAILED Reason: Cancelling due to failed test step Duration: 1549
TestCase: TC_TWO Status: FINISHED Reason: {} Duration: 1277
...
TestCase: TC_N Status: FAILED Reason: Cancelling due to failed test step Duration: 1282
Test Suite: TS_TWO
TestCase: TC_BlaBla Status: FINSHED Reason: {} Duration: 1280
...
나는 위의 정보가 사람을 도움이되기를 바랍니다.
내가 어딘가에서 얻을 것입니다 런타임에 페이로드를 전달하여 API를 테스트하고 싶습니다. –