In the ver 1.19.5 com.kazurayam.visualtesting.VisualTestingListenerImpl class has such code fragment:
void beforeTestSuite(TestSuiteContext testSuiteContext) {
// read TestSuiteId and ExecutionProfile of the last executed test suite
// from GlobalVariables.json file
if (Files.exists(GLOBAL_VARIABLES_JSON)) {
List<String> names = [MGV.LAST_EXECUTED_TESTSUITE_ID.getName(), MGV.LAST_APPLIED_EXECUTION_PROFILE.getName()]
Reader reader = new InputStreamReader(new FileInputStream(GLOBAL_VARIABLES_JSON.toFile()), "utf-8")
Map<String, Object> gvs = GlobalVariableHelpers.read(names, reader)
for (String name in gvs.keySet()) {
GlobalVariableHelpers.ensureGlobalVariable(name, gvs.get(name))
WebUI.comment("GlobalVariable.${name} has value \"${gvs.get(name)}\" loaded from ${GLOBAL_VARIABLES_JSON}")
}
} else {
WebUI.comment("${GLOBAL_VARIABLE_JSON} file is not found")
}
void afterTestSuite(TestSuiteContext testSuiteContext) {
// write the id of Test Suite which was last executed into a GlobalVariable, and write it into json file.
// write the Execution Profile name as well.
// It is necessary to pass the info via file to the next TestSuite run.
// Because a GlobalVariable is TestSuite-scoped; it is not automatically passed across TestSuite boundaries.
def lastExecutedTestsuiteId = this.getRelativeTestSuiteId(testSuiteContext)
def lastAppliedExecutionProfile = RunConfiguration.getExecutionProfile()
GVH.ensureGlobalVariable(ManagedGlobalVariable.LAST_EXECUTED_TESTSUITE_ID, lastExecutedTestsuiteId)
GVH.ensureGlobalVariable(ManagedGlobalVariable.LAST_APPLIED_EXECUTION_PROFILE, lastAppliedExecutionProfile)
WebUI.comment("GlobalVariable.${ManagedGlobalVariable.LAST_EXECUTED_TESTSUITE_ID} is set to ${lastExecutedTestsuiteId}")
WebUI.comment("GlobalVariable.${ManagedGlobalVariable.LAST_APPLIED_EXECUTION_PROFILE} is set to ${lastAppliedExecutionProfile}")
//
Files.createDirectories(GLOBAL_VARIABLES_JSON.getParent())
List<String> names = [MGV.LAST_EXECUTED_TESTSUITE_ID.getName(), MGV.LAST_APPLIED_EXECUTION_PROFILE.getName()]
Writer writer = new OutputStreamWriter(new FileOutputStream(GLOBAL_VARIABLES_JSON.toFile()), "utf-8")
GVH.write(names, writer)
These codes are very important. But difficult to explain to others. Too messy for others to understand.
I should make a new class com.kazurayam.visualtesting.GlobalVariablesPersistence. I should move these code into the GlobalVariablesPersistence class. I should write unit-tests for the new class. And I should write clear description about the class; what it is designed for.
In the ver 1.19.5
com.kazurayam.visualtesting.VisualTestingListenerImplclass has such code fragment:These codes are very important. But difficult to explain to others. Too messy for others to understand.
I should make a new class
com.kazurayam.visualtesting.GlobalVariablesPersistence. I should move these code into the GlobalVariablesPersistence class. I should write unit-tests for the new class. And I should write clear description about the class; what it is designed for.