Careeroza
Variables and Data Types
Storing Test Data
A test script is full of values: a URL, an email, an expected price, a count of products. You store them in variables. This page is a quick refresher; for full details see the Java material.
| Type | Holds | Test example |
|---|---|---|
String | text | String email = "[email protected]"; |
int | whole numbers | int expectedCount = 24; |
double | decimals | double price = 1299.50; |
boolean | true / false | boolean isLoggedIn = false; |
Example
Example
Variables for one login test:
public class Main {
public static void main(String[] args) {
final String BASE_URL = "https://shopease.example.com"; // final = constant
String email = "[email protected]";
String password = "Test@123";
int timeoutSeconds = 10;
boolean headless = true;
System.out.println("Open " + BASE_URL + "/login");
System.out.println("Login as " + email + " (password length " + password.length() + ")");
System.out.println("Wait up to " + timeoutSeconds + "s, headless = " + headless);
}
}Output
Open https://shopease.example.com/login Login as [email protected] (password length 8) Wait up to 10s, headless = true
Tip: Use final and UPPER_CASE names for values that never change, such as the base URL. Later these move to a config file.