assert_
glossary ↓ downloads
track: java · selenium
suite 01 · tooling & environment

Running tests from the terminal

Tooling & environment12 min
as a manual tester

You run tests by clicking through the app.

in automation

CI servers have no mouse. One command — mvn test — runs your whole suite, which is exactly what Jenkins or GitHub Actions will do.

IntelliJ's green arrow is fine for development, but automation's whole point is running without a human. The terminal command you learn here is literally what CI pipelines execute in Suite 07.

The one command

terminal — from your project folder
$ mvn test

Maven then: downloads any missing dependencies → compiles your code → runs every test class → prints a summary. (If mvn isn't on your system path, use the wrapper the starter ships with: ./mvnw test on Mac/Linux, mvnw test on Windows — same thing, zero install.)

Reading the output like a pro

what success looks like
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running HelloTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS

Two words matter: BUILD SUCCESS or BUILD FAILURE. On failure, scroll up to the first red block — a Failure means an assertion didn't match (a real test failing its check); an Error means the code broke before asserting (element not found, null pointer). Distinguishing those two is a daily automation skill: failures point at the app, errors point at your test.

Useful variations

terminal
$ mvn test -Dtest=HelloTest        # run one class only
$ mvn clean test                   # wipe old builds first (fixes weirdness)
Connect the dots: Suite 07's CI lesson is essentially "make a robot run mvn test on every commit and email you the result." You now know the exact command the robot runs.
⚠ when it breaks — the classics
'mvn' is not recognized
mvn : The term 'mvn' is not recognized as the name of a cmdlet…

Fix: Maven is bundled with IntelliJ but not on your system PATH. Use the wrapper the starter ships with — mvnw test on Windows — or run from IntelliJ's built-in terminal.

Maven runs but finds zero tests
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

Fix: Surefire only picks up classes whose names end in Test, located under src/test/java. Check both, then re-run.

Maven complains about the Java release
[ERROR] … error: release version 21 not supported

Fix: Maven is running with an older JDK than the project targets. Check JAVA_HOME points at your JDK 21 folder, reopen the terminal, confirm with mvn -version.

⚡ exercise · run, break, and read
  1. Run mvn test (or ./mvnw test) in your starter project. Find the Tests run / Failures line.
  2. Break an assertion in HelloTest.java, run again, and identify the failure block in the output. Note it says Failures: 1.
  3. Now break the code (e.g., call .length() on a String set to null), run again, and see it report an Error instead. Fix everything and get back to BUILD SUCCESS.
key takeaways
  • mvn test compiles and runs the whole suite with no IDE and no mouse.
  • BUILD SUCCESS / FAILURE is the headline; the first red block is the story.
  • Failures = assertion mismatch (suspect the app). Errors = broken test code (suspect the test).
← Git basics — version control for testers Suite test →