Files .projet, *.testcase.prop

I have created a test listener for getting the test case name and test case ID before a test case runs. My listener class looks like this;
class Sample
{
@BeforeTestSuite
def sampleBeforeTest(TestCaseContext context)
{
println context.getTestCaseId()
String status= context.getTestCaseStatus()
println status
}
}

But when I run the suite, I am getting null pointer exception. Please see the below snapshot.

Please let me know how do I get the test case name and ID from context object.

You’re using @BeforeTestSuite with TestCaseContext - note Suite with TestCase. Try:

  @BeforeTestCase
  def beforeTestCase(TestCaseContext testCaseContext) { ... }

or…

@BeforeTestSuite
def beforeTestSuite(TestSuiteContext testSuiteContext) { ... }
1 Like