Forum Discussion

dweakley's avatar
dweakley
Occasional Contributor
11 years ago

Project ActiveEnvironment

I'm creating a JUnit test to run some test suites I have in a soapUI pro project file.
My function is below. Even after setting the project's activeEnvironment, the next line prints "Default" to the console.

What's happening is my environments contain specific endpoints, and when I run the code below, the console states no endpoint could be found for the request.

also, the code below regarding ignoring disabled suites doesn;t seem to work.
I looped through and printed out suite names to the console and the disabled suites were listed, as well.



 @Test
public void runSoapUITestSuite4() throws Exception {
WsdlProject project = new WsdlProject(SoapUIConfiguration.PROJECT_FILE);

project.setPropertyValue("activeEnvironment", "PRODUCTION");

System.out.println("Project Propeties activeEnvironment: " + project.getActiveEnvironment().getName());

List<TestSuite> testSuites = project.getTestSuiteList();

for (TestSuite suite:testSuites) {
if (!suite.isDisabled()) {

List<TestCase> testCases = suite.getTestCaseList();

for (TestCase testCase:testCases) {
if (!testCase.isDisabled()) {
System.out.println("Preparing to run TestSuite: " + suite.getName() + " TestCase: " + testCase.getName());
TestRunner runner = testCase.run(new PropertiesMap(), false);
assertEquals(Status.FINISHED, runner.getStatus());
}
}
}
}
}
  • The Disabled suites should not run if they are disabled. We dont really support Scri[ting but I suggest that you use groovy, its a bit more lenient in SoapUI. To select an environment you just have to do this:

    testRunner.testCase.testSuite.project.setActiveEnvironment("staging")
  • dweakley's avatar
    dweakley
    Occasional Contributor
    I'd rather not use Groovy. The Java code should work. Am I using it wrong?

     project.setPropertyValue("activeEnvironment", "PRODUCTION");
  • this will be handled in our case system, I see that the case 00037933 was created for you and it has been handed down to the Dev team. Let me know if you have further questions.

    Regards,
    Temil