Time to build. These exercises take you from zero to a fully configured Maven project that's ready for CI/CD. Do them in order — each one builds on the previous.
Exercise 1: Create a Maven Project from Scratch
Open IntelliJ > File > New > Project > Maven Archetype > maven-archetype-quickstart
Set groupId to com.testerrank and artifactId to banking-automation
Replace the generated pom.xml with the complete pom.xml from the POM Anatomy lesson
Create the folder structure: src/test/java/com/testerrank/base/, pages/, tests/, listeners/
Create a simple BaseTest.java with @BeforeMethod that reads browser from System.getProperty()
Create LoginTest.java with one @Test method that opens the TesterRank Banking Portal
Run mvn clean test from the terminal — verify the test executes
Exercise 2: Set Up Multiple Test Suites
Create testng-smoke.xml in src/test/resources — include only LoginTest
Create testng-regression.xml in src/test/resources — include all test classes
Run: mvn clean test -DsuiteXmlFile=src/test/resources/testng-smoke.xml
Run: mvn clean test -DsuiteXmlFile=src/test/resources/testng-regression.xml
Verify different numbers of tests execute for each suite
Exercise 3: Configure Profiles
Add browser profiles (chrome, firefox) to pom.xml
Add environment profiles (local, staging) to pom.xml
Add suite profiles (smoke, regression) that set suiteXmlFile property
Test: mvn clean test -Pchrome — should use Chrome
Test: mvn clean test -Pfirefox,smoke — should use Firefox with smoke suite
Run mvn help:active-profiles to verify which profiles are active
Exercise 4: Debug a Broken Build
Intentionally change a dependency version to something that doesn't exist. Run mvn clean test. Read the error message carefully.
Fix the version. Now intentionally put a test class in src/main/java instead of src/test/java. Run mvn clean test. What happens?
Move it back. Now rename your test class to LoginScenarios.java (doesn't end with Test). Run mvn test. How many tests run?
Run mvn dependency:tree and study the output. Find all transitive dependencies of Selenium.
Run mvn versions:display-dependency-updates to see if any of your libraries have newer versions.
Exercise 5: Prepare for CI
bash
# Simulate what Jenkins would run:
# Step 1: Clone the repo (you already have it)
# Step 2: Run smoke tests headlessly
mvn clean test -Pchrome,smoke -Dheadless=true
# Step 3: Check the reports
ls target/surefire-reports/
# Step 4: Run regression tests
mvn clean test -Pchrome,regression -Dheadless=true
# Step 5: If all pass, you're CI-ready
After completing these exercises, your project is genuinely CI/CD ready. The same Maven commands you just ran locally are exactly what Jenkins, GitHub Actions, or any CI tool will run. The only difference is CI runs them in a Docker container or a cloud VM.