khvadagiani
3 years agoNew Member
NullPointerException when trying use "testCase" inside the class
Hello. I want to create my own jar file to avoid code duplication. When I created class and tested it without jar in the groovy test step, I got this error;
Cannot get property 'testCase' on null object. I need get test step name in my code. Same error when i'm calling same class from jar There is code example:
import java.security.MessageDigest
class TestClass {
private static def log
private static def context
private static def testRunner
private static def testCase
TestClass(log, context, testRunner,testCase) {
this.log = log
this.context = context
this.testRunner = testRunner
this.testCase = testCase
}
public static String GetTestSuiteName(){
def name = testRunner.testCase.testStep.getName();
return name
}
}
TestClass.GetTestSuiteName()