Forum Discussion

Ch00k's avatar
14 years ago

TestRunner logging

I've got a test suite, which consists of one test case, which is being cloned with this script:

import java.util.*;
import com.eviware.soapui.support.*;
import com.eviware.soapui.impl.wsdl.*;
def groovyUtils = new GroovyUtils(context);
def csvpath = groovyUtils.projectPath + "\\attacks_dict.csv"; //Define relative CSV path
BufferedReader input = new BufferedReader(new FileReader(new File(csvpath).getAbsoluteFile())); //Read the CSV file
String[] rows = input.text.split('\r\n'); //Line separator

for(int i = 0; i < rows.size(); i++){

def template = "TestCase";
def counter = i + 1;
def tsname = template + counter;
context.getTestSuite().cloneTestCase(context.getTestSuite().getTestCaseByName("TestCase"), tsname);
context.getTestSuite().getTestCaseByName(tsname).setDisabled(false);
context.getTestSuite().getTestCaseByName(tsname).getTestStepByName("TestCase").setDisabled(false);
String string = rows[i];
String contains = "CDATA";
//If string contains "CDATA", do not append CDATA tags to it
if (string.indexOf(contains) != -1) {
context.getTestSuite().setPropertyValue("data", string); //Write each line into a test suite property
//Else append CDATA tags to the string
} else {
data = "<![CDATA[" + string + "]]>";
context.getTestSuite().setPropertyValue("data", data); //Write each line into a test suite property
}
context.getTestSuite().setPropertyValue("lineno", Integer.toString(i)); //Convert lineno property value to string
//context.getTestSuite().testCases[tsname].run(new com.eviware.soapui.support.types.StringToObjectMap(), false); //Run test case
}

input.close();


This script is a test suite setup script. What it does is it takes the only currently existing test case in the suite and clones it to create ~350 more test cases.
When I run the test suite from soapUI, it seems to work fine (first the test suite is being populated with all the 350 test cases, which are created by the setup script, then all of them are being run), but when I try to run this suite from the terminal with testrunner.bat with JUnit reports, it produces no log. The log I'm getting is the following:

Running soapUI TestRunner for [project]
directory: C:\Program Files\eviware\soapUI-3.5.1\bin\.
command: cmd.exe /C testrunner.bat -sTestSuite -r -j D:\Projects\project\local_test_run\tests\service\project\project.xml
soapUI 3.5.1 TestCase Runner
Configuring log4j from [C:\Program Files\eviware\soapUI-3.5.1\bin\soapui-log4j.xml]
16:19:50,158 INFO [DefaultSoapUICore] initialized soapui-settings from [C:\Documents and Settings\me\soapui-settings.xml]
16:19:50,861 INFO [WsdlProject] Loaded project from [file:D:/Projects/project/local_test_run/tests/prj/project/project.xml]
16:19:51,705 INFO [SoapUITestCaseRunner] Running soapUI tests in project [project]
16:19:51,705 INFO [SoapUITestCaseRunner] Running TestSuite [TestSuite], runType = SEQUENTIAL
16:19:54,533 INFO [SoapUITestCaseRunner] TestSuite [TestSuite] finished with status [FINISHED] in 2812ms

SoapUI 3.5.1 TestCaseRunner Summary
-----------------------------
Time Taken: 2821ms
Total TestSuites: 1
Total TestCases: 0 (0 failed)
Total TestSteps: 0
Total Request Assertions: 0
Total Failed Assertions: 0
Total Exported Results: 0


I'll appreciate if anyone could point to what am I doing wrong and how to make TestRunner produce logs for every test case, created by the script.

Thanks!

2 Replies

  • andrew_laser's avatar
    andrew_laser
    Occasional Contributor
    I've got the same issue when using testRunner from soapUI and from command line (testRunner.bat)

    ...
    13:22:44,369 INFO [SoapUITestCaseRunner] Project [Project_CloneTestCases] finished with status [FAILED] in 4458ms
    SoapUI 4.0.0 TestCaseRunner Summary
    -----------------------------
    Time Taken: 3973ms
    Total TestSuites: 1
    Total TestCases: 0 (0 failed)
    Total TestSteps: 0
    Total Request Assertions: 0
    Total Failed Assertions: 0
    Total Exported Results: 0


    Although there are 6 test cases (5 passed, 1 failed). BTW, NO log files at all are created.
    The only workaround I've found so far is to save the project after the cloned test cases are created.
    The problem is, don't know how to do it during project execution i.e. using script.

    The following code doesn't help.

    testSuite.project.save()


    The correct log appears only if I click File -> Save Project manually.

    Any ideas or workarounds for this issue?
  • cryptton2004's avatar
    cryptton2004
    Occasional Contributor

    I managed to get something similar to work by adding this:

    project = context.testCase.testSuite.project
    project.save()
    project.getWorkspace()

     

    When I first run in from testrunner, I get no results. The second time I run it, it works.
    I guess that somehow the workspace doesn't know about the dynamically created tests, that's why it works starting with the second time. Now, next step would be to find a way to 'reload' the project in the same run, in order to also have the results from the new dynamically created test cases. If I find a way to do it, I'll let you know, but any help is appreciated .