Forum Discussion

Chris_Osthaus's avatar
Chris_Osthaus
Occasional Contributor
16 years ago

Running test step in TearDown script

Hi All,

This may be an easy one - I'm simply trying to build TearDown scripts for my various Test Cases, and all I really need to do is to execute various Test Steps in these scripts.

However, I can't seem to get the execution to work - what's the simplest way to do this?  I have tried running something like 'testRunner.runTestStepByName("TestStepName")' - and this will work if I execute the TearDown script all by itself - but it does not execute at the end of running the Test Case. 

Thanks!
  • Hi Chris,


    I assume you running your test case from command-line or from UI. Is that correct?

    You have actually pointed out a bug in soapUI. Thank you for that!
    We'll fix it as soon as possible.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzillla
  • Chris_Osthaus's avatar
    Chris_Osthaus
    Occasional Contributor
    Thanks for the reply - just getting back to this.  I'm running the test case from the UI. 

    Like I said earlier, the method runTestStepByName executes properly when I run the TearDown script manually by itself.  However, it doesn't execute when the test case itself runs. 

    Do you know when this will be fixed?  In a nightly build?

    Thanks!
  • Hi,

    Actually, we can't decide if this is a bug or intended behaviour. The reason your script isn't working is that testRunner.runTestStepByName only works while the test is running, and the TearDown script runs after the test has completed, and thus is not running any more. A workaround that you can use it to manually run the teststep, which you can do with the following line of code in your TearDown script:


    testRunner.testCase.testSteps['TestStepName'].run(testRunner, context)


    Regards,
    Dain
    eviware support
  • Usha_Kodali's avatar
    Usha_Kodali
    Frequent Contributor
    Hi Dain,
    I tried running DataSink in TearDown Script...it did not run in teardown script.
    testRunner.testCase.testSteps['DataSink'].run(testRunner, context)
    DataSink has property=status and value=${=testRunner.getStatus()}

    i gave the excel to write into...nothing is written into the excel...please assist me
    How to get teststep status of a particular stepstep...
  • Dalimonster's avatar
    Dalimonster
    Occasional Contributor
    Would this apply for running a testcase as well?
    I'm trying to run a teardown testcase that will remove the data I created from the database, but the testcase doesn't get executed.
  • Hello Usha,

    I'm not quite sure why it's not working. Please make sure that the TestStep is enabled when you try to run it. (If you need it disabled for the test you can enable it during the TearDown script). However, if you are trying to run a TestStep in another TestCase then you will need to take some additional steps to get it to work. Here is an example of doing so:


    def testStep = testRunner.testCase.testSuite.testCases['TestCase 2'].testSteps['DataSink']

    testStep.prepare(testRunner, context)
    testStep.run(testRunner, context)
    testStep.finish(testRunner, context)



    Dalimonster,

    Yes, you should be able to run a TestCase in a similar way.
    Note that the parameters for the method call is a bit different:


    testCase.run(null, false)


    The first argument is an optional String to Object map for the context, the second is whether to run asynchronously or not.

    Regards,
    Dain
    eviware