Forum Discussion

mchelikani's avatar
mchelikani
Contributor
13 years ago

Override Global Property TestSuiteRunListener.beforeTestCase

I would like to Override the Global Property before TestCase Runs.

Should I be Using TestSuiteRunListener.beforeTestCase or TestRunListener.beforeRun. when should we use these?


Appreciate if I can syntax to override the property.

How do I get TestCase Name?

How do I get Instance of TestSuiteRunner?

3 Replies

  • I would like to get TestCase Name as well in TestSuiteRunListener.beforeTestCase.

    Appreciate for sample code.
  • [quote="mchelikani"]I would like to Override the Global Property before TestCase Runs.

    Should I be Using TestSuiteRunListener.beforeTestCase or TestRunListener.beforeRun. when should we use these?


    Appreciate if I can syntax to override the property.

    How do I get TestCase Name?
  • Hi!

    TestSuiteRunListener.beforeTestCase is called just before a TestCase is executed. If you have more than one TestCase configured it will be called once for each TestCase.
    TestRunListener.beforeRun is called just before a TestSuite is executed.

    Thus, you should probably use TestSuiteRunListener.beforeTestCase.

    The syntax for retriving the TestCase name from the event handler is:

    testCase.name


    if you would like to use the TestRunListener.beforeRun for some reason it's:

    log.info testRunner.testSuite.getTestCaseAt(0).name


    where 0 is the index of the first TestCase.

    --
    Regards

    Erik
    SmartBear Sweden