Testing Commands

When developing large projects, it is good practice to add automated tests for your code. This section of the documentation describes how to use the commandapi-bukkit-test-toolkit dependency along with MockBukkit and JUnit to test the usage of commands registered with the CommandAPI.

For a big-picture view, you can find example projects that include automated tests in the CommandAPI GitHub repository.

Developer's Note:

Many methods have not yet been implemented in the test toolkit. Most notably, only primitive arguments, String arguments, literal arguments, and the IntegerRangeArgument are fully implemented. The EntitySelectorArgument, PlayerArgument, and OfflinePlayerArgument should mostly work, though target selector arguments (e.g. @e[type=pig]) are not yet implemented.

If a test ends up calling a method that has not yet been implemented, an UnimplementedMethodException will be thrown, causing the test to fail. If you see an UnimplementedMethodException, please tell us about it with a GitHub Issue or a message in the CommandAPI Discord. Pull requests are also always welcome!

In the short term, you can try to resolve an UnimplementedMethodException by implementing the method yourself. The process for doing that is described here.