git clone 'git://'

Maven test mode

MELPA MELPA Stable Build Status

This minor mode provides some enhancements to java-mode in order to use maven test tasks with little effort. It's largely based on the philosophy of `rspec-mode' by Peter Williams. Namely, it provides the following capabilities:

Check the full list of available keybindings at maven-test-mode-map.

maven-test-mode defines a derived minor mode maven-test-compilation which allows one to jump from compilation errors to text files.


You can install via MELPA, or manually by downloading maven-test-mode and adding the following to your init file:

(add-to-list 'load-path "/path/to/maven-test-mode")
(require 'maven-test-mode)


If maven-test-mode is installed properly, it will be started automatically when java-mode is started.


Output format

If you prefer the more ‘verbose’ maven output, change the default of maven-test-test-task-options:

(setq maven-test-test-task-options "")

Toggling between implementation and tests

In order to map between the class file and it's test, maven-test-mode uses the variable maven-test-class-to-test-subs. This variable specifies a list of substitution pairs (REPLACE . BY) that will be applied to the class file path in order to find the corresponding test file:

(s-replace-all subs (buffer-file-name))

If your project does not comply with the default convention, you need to change the value of this variable.

Running test defined at point

In order to identify which test method is immediately defined before point, maven-test-mode uses the regexes defined at maven-test-test-method-name-regexes. If your test method definition does not match the default regexes, you need to add your custom regex to the list with something like:

(add-to-list 'maven-test-test-method-name-regexes "my-special-regex")


Love Emacs? Great, help out by contributing. The easiest way to contribute is to checkout the git project, make a change and then submit a pull request.

Note on Patches/Pull Requests


This package is largely inspired in rspec-mode by Peter Williams.