Forum Discussion

Liam_Cooke's avatar
16 years ago

Knowing where a TestCase is being run from

Hi,

I was wondering if it is possible to determine whether the current TestCase is being run:
- Individual
- As part of a TestSuite
- As a collection of TestSuites from the Project Level

At the moment I'm using a property that's setup in the TestSuite setup script to determine this, but was wondering if there was a better way. Many thanks in advance.


Regards
  • Hello,

    Hmm, I don't think there is a better way really... So if your solution works then I would stick with it. If you don't wish to use a Property, you could simply add it to the RunContext. For example, if you add the following event handlers:


    //ProjectRunListener.beforeRun
    if(context.level == null)
    context.level = "Project"

    //TestSuiteRunListener.beforeRun
    if(context.level == null)
    context.level = "TestSuite"

    //TestRunListener.beforeStep
    if(context.level == null)
    context.level = "TestCase"


    You can then access the level variable using a Property Expansion: ${level}, or in a Groovy Script using: context.level

    I'm not really sure if this is any better than what you already have. As I said, if it already works, I'd stick with it.

    Regards,
    Dain
    eviware.com