What are you asking?
This is meant as a follow-up to this question not being answered.
DISCLAIMER
Before we jump into the problem description, I should point out that, when we’re talking about “practice profiles”, we are NOT referring to the Execution Profiles. We are referring to some business data type.
Problem
In the Global Variables, we are still forced to go to Script mode, just to change the state of a variable of some business type, for example with practiceProfile
.
We have this method on our singleton class PracticeProfileHandler
called getPracticeProfile()
, which accepts the practice name and returns a practice profile object from the data store that has that practice name.
Right now, using it looks like this:
We have to spell out the fully-qualified package name for it ! YIKES.jpg
Another part of the problem: Test cases
Also, with very few exceptions, we have Test Cases with a practiceProfile
variable that, defaults to GlobalVariables.practiceProfile
.
What changing the test case variable state looks like
Suppose we want to add some family member leads to a practice, and that was the only thing we wanted to do. Run no other test cases. Just that one to create some family members.
We realize that the default practice profile state may be different from what we want to use. So, we go to set it in the Variables tab…
For some odd reason, we can’t point to PracticeProfileHander.GetInstance().getPracticeProfile()
in the variables tab… I can’t retrieve any methods on that PracticeProfileHandler
, nevermind the static one that we need to get first…
…and forget chaining methods!
If we wanted to not use that default state (for example, if we wanted to add member leads to just that is in the GlobalVariables.practiceProfile
, we have to go into Variables (Script mode) tab and do the same thing we did for that global variable…
What does your PracticeProfileHandler
look like?
Like this:
public class PracticeProfileHandler extends BaseRecordHandler<PracticeProfile> {
private static PracticeProfileHandler _instance;
private PracticeURLHandler childPracticeURLHandler;
private OrganizationNameHandler childOrgNameHandler;
@Keyword
public static PracticeProfileHandler GetInstance() {
if (this._instance == null) {
this._instance = new PracticeProfileHandler();
}
return this._instance;
}
protected PracticeProfileHandler() {
super("./Practice Profiles.xlsx");
}
@Keyword
public PracticeProfile getPracticeProfile(String practiceName) {
return new PracticeProfile(this.childOrgNameHandler.getOrganizationName(practiceName),
practiceName,
this.childPracticeURLHandler.getPracticeURL(practiceName));
}
//... more business logic...
}
What are you wanting to about it?
I have a few ideas, that wouldn’t involve shotgun surgery to the literal hundreds of test cases that take a practiceProfile
variable:
- if there is some way to have some wrapper method in package
internal
or any other package that the test case XML recognize without having to spell it out, that will call myPracticeProfileHandler.GetInstance().getPracticeProfile(profileName)
, whereprofileName
is the name of the practice profile we want to use - manipulate the
TestCaseContext
inside the test listener@BeforeTestCase
method, to, if it sees apracticeProfile
equal to some string, fetch the practice profile into that variable, by that name. This would allow the user to simply pass in the practice name.
Both of these methods feel a bit…hacky… @kazurayam , Katalon community, any ideas on how I can solve this once and for all without shotgun surgery?
NOTE: question has been updated for more clarity