test-watch-maven-plugin

June 6, 2026 · View on GitHub

Builds Maven Central License Java

Vitest-inspired watch mode for Maven tests. Save a file, see your test results instantly — no IDE required.

screenshot


Why?

You're working on a Java project. You change a class. Now you need to know if the tests still pass.

Your options:

  • mvn test — slow, runs everything, 30+ seconds of waiting
  • Infinitest — great, but IDE-specific (Eclipse/IntelliJ only), and doesn't work for everyone's setup
  • Switch to Gradle just for --continuous? Overkill.

test-watch-maven-plugin gives you the same instant feedback loop you get with Vitest, Jest, or cargo watch — but for Maven. Save a .java file, and only the affected tests run. In parallel. With readable output.


Features

  • 👀 File watching — monitors your source tree for changes
  • 🎯 Smart test selection — only re-runs tests affected by changed files (configurable patterns)
  • Parallel execution — runs tests concurrently for faster feedback
  • 📊 Readable summaries — clean pass/fail output, not Maven's wall of text
  • 🔌 Maven-native — no extra daemon, no IDE plugin, just mvn
  • 🧩 Configurable — include/exclude patterns, test matching, parallel toggle, smart selection toggle

Requirements

  • Java JDK 11+
  • Maven 3.6+

Quick Start

Add the plugin to your pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>io.github.albilu</groupId>
            <artifactId>test-watch-maven-plugin</artifactId>
            <version>1.0.0</version>
            <configuration>
                <includes>
                    <include>**/*.java</include>
                </includes>
                <excludes>
                    <exclude>**/target/**</exclude>
                </excludes>
                <testPattern>**/*Test.java</testPattern>
                <parallel>true</parallel>
                <smartSelection>true</smartSelection>
            </configuration>
        </plugin>
    </plugins>
</build>

Then run:

mvn test-watch-maven-plugin:test

The plugin watches your source files. Change anything, save, and tests re-run automatically.

Configuration

OptionDefaultDescription
includes**/*.javaFiles to watch for changes
excludesPatterns to ignore (e.g., **/target/**)
testPattern**/*Test.javaPattern to identify test files
paralleltrueRun tests in parallel
smartSelectiontrueOnly run tests affected by changed files

How It Works

  1. Plugin starts a file watcher on your configured source paths
  2. When a .java file changes, the plugin identifies which test files to run using testPattern
  3. With smartSelection: true, only tests matching changed source files are executed
  4. Tests are dispatched to Maven's invoker framework (parallel when enabled)
  5. Results are aggregated into a clean summary

vs Alternatives

test-watch-maven-pluginInfinitestmvn test -pl ...Gradle --continuous
Watch mode
Maven-native❌ (IDE plugin)
IDE-agnostic
Smart selection
Parallel tests
CLI-first

Contributing

Contributions welcome. Please open issues or PRs against this repository. Follow existing code style and include tests for new behavior.

License

MIT — see LICENSE.