Important context
Long ago, I followed these steps to create a test listener.
I have since then, some time ago, split out two important methods, that are needed in test suite setup/teardown hooks: setUpDriver()
and closeDriver()
.
I can use these successfully in a test suite setUp()
or tearDown()
method hook, for example:
@TearDown
def tearDown() {
NewTestListener listener = new NewTestListener();
listener.setUpDriver();
PracticePage.DeleteContractsIfNeeded(GlobalVariable.practiceProfile);
GlobalVariable.practiceProfile = defaultProfile;
PracticeProfileHandler.GetInstance().close();
listener.closeDriver();
}
OK, what’s the problem?
Problem is that I am using these across multiple test suites, just jumped back into reviewing my code for two of the test suites whose tearDown
methods I had to update…
…and to do that update, I had to open another test suite that’s using the NewTestListener
in their methods, just to copy and paste the NewTestListener
stuff…
It’s time to abstract that out!
I try that…
// all the other imports
import NewTestListener;
public final class SMDTestCaseUtils {
// ...other methods in this class...
public static void DoListenableAction(Closure onAction) {
NewTestListener listener = new NewTestListener();
listener.setUpDriver();
onAction();
listener.closeDriver();
}
}
After the attempt, I face the error:
Groovy:unable to resolve class NewTestListener
I know that this NewTestListener
that Katalon created for me, is in default package…my utils class, obviously is not…
…so what is the issue with bringing it in the test case utils keyword class?