Forum Discussion

corki's avatar
corki
Contributor
16 years ago

HOW TO CREATE dynamically newTestSuite, newTestCase and new TestStep in project

Hi all,

    this toppic should help a LOT of people:

    can I get just simple groovy code,
which will be able to create

1. - an absolutely independent new TestSuite,
2. - inside it new TestCase,
3. - and inside it, new TestStep (specialy TEST REQUEST step).
4. - mayby also  new TestStep (specialy groovy Scritp with 1 line of code)


I already know how to create/remove assertions

(mayby when I am creating new assertions - Script assertion), what is the property for "code" of this assertions. like
  myAssertion.name "script1";
  myAssertion.code?? = " log.info('hello'); ";

Great Thank for every help.

4 Replies

  • After 1 day googling and working I made this as answear for my own question

    -------------------------------------------------------------------------

    def testSuiteName = "my_TestSuite";
    def testCaseName = "my_TestCase";
    def testStepName  = "my_TestRequest_step";
        def interfaceName  = "FuelPriceSearchSOAP";
            def operationName = "GetFuelPrices";
    def assertion_xPathName = "my_xPath_Match";
    def assertion_ScriptName = "my_ScriptAssertion";

    // Create New Test Suite ,... or USE Existing ========================================================
    if( testRunner.testCase.testSuite.project.getTestSuiteByName( testSuiteName) == null )  newTestSuite = testRunner.testCase.testSuite.project.addNewTestSuite( testSuiteName );
    else                                                                                                                                      newTestSuite = testRunner.testCase.testSuite.project.getTestSuiteByName( testSuiteName );



    // Create New Test Case =======================================================================
    def newTestCase = newTestSuite.addNewTestCase( testCaseName );



    // Create New Test Step ========================================================================
    //testRunner.testCase.addTestStep( "properties", "my Dolly TestStep - Properties" );
    // def newTestStep = newTestCase.addTestStep( "request",  testStepName );

    // get operation
    def op =testRunner.testCase. testSuite.project.interfaces[interfaceName].operations[operationName];

    // create config
    def config = com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory.createConfig( op, testStepName );

    // add to testcase
    def newTestStep = newTestCase.addTestStep( config );


    // set NEW Request for testStep
    newTestStep.setPropertyValue("request", "lala");

    // read Request from testStep
    def testStepRequest = newTestStep.getPropertyValue("request");
    log.info(testStepRequest);
  • gurpreets's avatar
    gurpreets
    Occasional Contributor
    Hey awesome script.. thanks

    Is there a way I can supress the UI boxes that emerge. ie. the box where we need to select operation to invoke for request.. I need to do that too using my groovy script.

    Is there a way.