How to pass value from @BeforeTestCase to @AfterTestCase (Test Listeners)

Please explain “doesn’t do the trick” (if you want help with a problem, you need to explain in detail what exactly is going wrong).

This works:

@BeforeTestCase
  def beforeTestCase(TestCaseContext testCaseContext) {
    GlobalVariable.RANDOM_NAME = "russ"
  }

  @AfterTestCase
  def afterTestCase(TestCaseContext testCaseContext) {
    WebUI.comment('RANDOM_NAME: ' + GlobalVariable.RANDOM_NAME)
  }

Also, please follow this advice:

1 Like