TC getTestCaseStatus == PASSED when SetupTestCase fail

I have got a problem, i made simple test listener:
if (testCaseContext.getTestCaseStatus() == 'FAILED' || testCaseContext.getTestCaseStatus() == 'ERROR') { WebUI.takeScreenshot() Browser.printLogs() WebUI.refresh() CustomKeywords.'tools.Authentication.login'() }
This works as intended, but when my TC fails at @SetupTestCase(because of bad xpath) then testCaseContext.getTestCaseStatus() of this TC gets value “PASSED”. Is this a bug? I thought that it should get IGNORED or ERROR or something like that. Please help, i want to take screen shot when SetupTestCase fails but i don’t want to have that code in TS.

It seems you are using 2 approaches of setup/teardown processing:

  1. a Test Listener (a Groovy class under the <projectDir>/Test Listeners directory) — a testCaseContext object is available only in a Test Listener code
  2. ‘Script’ of a Test Suite — @SetupTestCase annotation is only available there

I think these 2 feature are totally unrelated beasts. They are not well designed to be used together.

If I were you, i will write all codes for setup/teardown aggregated in a TestListener. I personally never use Script of TestSuites.

A failure occurred inside a method annotated with @SetupTestCase in a TestSuite — it is not a failure occurred inside a TestCase.

The TestCase itself might be invoked after the @SetupTestCase method. Or rather the TestCase might NOT be started at all when a failure occurred in the @SetupTestCase method.

Therefore testCaseContext in a TestListener, I think, will be ignorant of any failure occurred inside @SetupTestCase in TestSuite Script.

Ok, the thing is that after @SetupTestCase fail, test listener is invoked anyway and there is some data about TC. That’s why i thought that i could use that to my advantage and throw there my code for handling exceptions. If there’s not status like IGNORED then i have to try diffrent approach.

Strange thing is that getTestCaseStatus returns PASSED, when TC never started. I thought that this might be a bug.

Anyway, thanks for your explanation.

I didn’t know that. And I would not mind it, ever.