Converting confirmation/error code on the fly

Finally, in the test method, we can call the lookup method to convert the code to the correct message. This eliminates having the same message in test data in multiple places and files, and only requires a change in one place, the property file:

@Test
public void
tc001_gmailLoginCreds(String rowID,
String description,
JSONObject testData)
throws Exception {

String user, password, getMessage;
GmailLoginPO gmail = new GmailLoginPO();

user = testData.get("username").toString();
password = testData.get("password").toString();

if ( testData.get("error") == null ) {
gmail.login(user, password);
gmail.signOut();
}

else {
getMessage = Utils.lookupMessage(
Global_VARS.exceptionMsgs,

testData.get("error").toString());

gmail.login(user, password, getMessage);
}
}

If the confirmation or error messages contain dynamic data such as usernames, account names, and so on, those can also be stuffed in on the fly with a quick replace call:

...

getMessage = JSONDataProvider.lookupMessage(
Global_VARS.exceptionMsgs,
testData.get("error").toString());

gmail.login(user,
password,
getMessage.replace("{USER}", Global_VARS.DEFAULT_USER);

...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.236.62