🌍 Ecosystem & CI/CD

Ecosystem & CI/CD: The env/ folder resembles a theater troupe's touring schedule: the same script (Java step code) is performed in Istanbul, Izmir, and Ankara — the actors do not

The env/ folder resembles a theater troupe's touring schedule: the same script (Java step code) is performed in Istanbul, Izmir, and Ankara — the actors do not change their lines by city, but each city's stage crew reconfigures the lighting/sound (base URL, timeout, credentials) for that specific venue. When you run gauge run --env test, the troupe answers "which venue are we in tonight" without ever touching the script. But if Java code can already read an environment variable with System.getenv(), why do you need a separate env/ folder structure? Because System.getenv() BAKES the configuration into the code — every new environment means either changed code or a pile of if/else branches; the env/ folder SEPARATES configuration from code entirely, so adding a new environment means a new properties file, not a new Java line. This is exactly the same philosophy as Spring's @ActiveProfiles or Maven's -P (profiles) mechanism in Java: the answer to "which environment am I in" comes from the command line, and the code stays oblivious to it. The real QA risk: if the base URL is hardcoded, a developer saying "let me quickly test this" could accidentally point a test meant for staging at prod — polluting production data. Having the env/ folder and the --env flag passed in CI visible EXPLICITLY in the pipeline definition makes this mistake catchable in code review.

🗂️ The env/ Folder and Environment Management

gauge init java always creates the env/default/ folder; the default.properties file inside it loads automatically on every run. To add another environment, you just create a new folder under env/ — for example env/test/. When the --env test flag is given, Gauge loads env/default/ first, then env/test/ (overriding the same keys if present, when they exist). This way the test environment only defines the keys that DIFFER (like base.url), without repeating the shared settings.

Micro Lab: Gauge spec-step binding practice

Replace the TODO line with the critical line from the expected solution. This is not a real runtime; the goal is to reinforce writing the correct structure in a controlled way.

The Merge Order of env/ Layers

env/default/ loads first

Settings shared across all environments and rarely changed (report folder, screenshot setting) load automatically on every run.

With --env test, env/test/ also loads

The folder for the environment named by the flag loads ON TOP of default.

On a key clash, test/ wins

If a key like base.url exists in both files, the value in env/test/ OVERRIDES default.

Read transparently on the Java side

Gauge loads these keys into System Properties; the code reads them with System.getProperty("base.url"), OBLIVIOUS to which environment it is in.