Global variables versus dynamic data
In cases like this where we want to use dynamic data, it sometimes makes sense to store property settings in global variables or constants that can be used throughout the test run.
Instead of always replacing the placeholders within the test methods, users can do it once in a central location for properties that are used frequently, assign them to a global variable, and then reference them in the test methods.
A good place to assign them is within the common setup class's @BeforeSuite
or @BeforeTest
methods:
// global variables class public class Global_VARS { public static String DEFAULT_URL = null; public static String DEFAULT_USR = null; public static String DEFAULT_PWD = null; }
// common setup class public static Properties testProps = new Properties(); @BeforeSuite(alwaysRun=true, enabled=true) protected void suiteSetup() throws Exception { testProps.load(new FileInputStream(Global_VARS.TEST_PROPS_PATH + ...