private void monitorTestSuite(TestSuite testSuite) { testSuite.addTestSuiteListener(testSuiteListener); for (int j = 0; j < testSuite.getTestCaseCount(); j++) { monitorTestCase(testSuite.getTestCaseAt(j)); } }
private void unmonitorTestSuite(TestSuite testSuite) { testSuite.removeTestSuiteListener(testSuiteListener); for (int j = 0; j < testSuite.getTestCaseCount(); j++) { TestCase testCase = testSuite.getTestCaseAt(j); unmonitorTestCase(testCase); } }
public void testAssert() throws Exception { WsdlProject project = new WsdlProject( "src" + File.separatorChar + "test-resources" + File.separatorChar + "sample-soapui-project.xml"); TestSuite testSuite = project.getTestSuiteByName("Test Suite"); com.eviware.soapui.model.testsuite.TestCase testCase = testSuite.getTestCaseByName("Test Conversions"); WsdlTestRequestStep testStep = (WsdlTestRequestStep) testCase.getTestStepByName("SEK to USD Test"); MockTestRunner testRunner = new MockTestRunner((WsdlTestCase) testStep.getTestCase()); MockTestRunContext testRunContext = new MockTestRunContext(testRunner, (WsdlTestStep) testStep); TestStepResult result = testStep.run(testRunner, testRunContext); WsdlTestRequestStepResult wsdlResult = (WsdlTestRequestStepResult) result; assertNotNull(wsdlResult); // assertEquals(TestStepResult.TestStepStatus.OK, wsdlResult.getStatus()); }
/** * Runs all test cases in given SoapUI TestSuite * * @param testSuite SoapUI TestSuite */ protected void run(TestSuite testSuite) { run(testSuite.getTestCaseList()); }
@Override public boolean runRunner() throws Exception { AnalyticsHelper.initializeAnalytics(); Analytics.trackSessionStart(); initGroovyLog(); assertions.clear(); String projectFile = getProjectFile(); WsdlProject project = (WsdlProject) ProjectFactoryRegistry.getProjectFactory("wsdl") .createNew(projectFile, getProjectPassword()); if (project.isDisabled()) { throw new Exception("Failed to load SoapUI project file [" + projectFile + "]"); } initProject(project); ensureOutputFolder(project); if (this.printAlertSiteReport) { testCaseRunLogReport = new TestCaseRunLogReport(getAbsoluteOutputFolder(project)); } log.info("Running SoapUI tests in project [" + project.getName() + "]"); long startTime = System.nanoTime(); List<TestCase> testCasesToRun = new ArrayList<TestCase>(); // validate testSuite argument if (testSuite != null && project.getTestSuiteByName(testSuite) == null) { throw new Exception( "TestSuite with name [" + testSuite + "] is missing in Project [" + project.getName() + "]"); } // start by listening to all testcases.. (since one testcase can call // another) for (int c = 0; c < project.getTestSuiteCount(); c++) { TestSuite suite = project.getTestSuiteAt(c); for (int i = 0; i < suite.getTestCaseCount(); i++) { TestCase tc = suite.getTestCaseAt(i); if ((testSuite == null || suite.getName().equals(testSuite)) && testCase != null && tc.getName().equals(testCase)) { testCasesToRun.add(tc); } addListeners(tc); } } try { // validate testSuite argument if (testCase != null && testCasesToRun.size() == 0) { if (testSuite == null) { throw new Exception( "TestCase with name [" + testCase + "] is missing in Project [" + project.getName() + "]"); } else { throw new Exception( "TestCase with name [" + testCase + "] in TestSuite [" + testSuite + "] is missing in Project [" + project.getName() + "]"); } } // decide what to run if (testCasesToRun.size() > 0) { for (TestCase testCase : testCasesToRun) { runTestCase((WsdlTestCase) testCase); } } else if (testSuite != null) { WsdlTestSuite ts = project.getTestSuiteByName(testSuite); if (ts == null) { throw new Exception("TestSuite with name [" + testSuite + "] not found in project"); } else { runSuite(ts); } } else { runProject(project); } long timeTaken = (System.nanoTime() - startTime) / 1000000; if (printReport) { printReport(timeTaken); } exportReports(project); if (saveAfterRun && !project.isRemote()) { try { project.save(); } catch (Throwable t) { log.error("Failed to save project", t); } } if ((assertions.size() > 0 || failedTests.size() > 0) && !ignoreErrors) { throwFailureException(); } return true; } finally { for (int c = 0; c < project.getTestSuiteCount(); c++) { TestSuite suite = project.getTestSuiteAt(c); for (int i = 0; i < suite.getTestCaseCount(); i++) { TestCase tc = suite.getTestCaseAt(i); removeListeners(tc); } } } }