Skip to content

CommandAPI Bukkit testing matrix

Jorel Ali edited this page Jan 12, 2023 · 2 revisions

To test the CommandAPI for Bukkit, we have a matrix of tests in commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test.

Testing matrix structure

The testing matrix structure is as follows:

commandapi-bukkit-test/
├── commandapi-bukkit-test-impl
├── commandapi-bukkit-test-impl-1.16.5
├── commandapi-bukkit-test-impl-1.17
├── commandapi-bukkit-test-impl-1.18
├── ...
├── commandapi-bukkit-test-tests
├── commandapi-bukkit-test-tests-1.16.5
├── commandapi-bukkit-test-tests-1.17
├── commandapi-bukkit-test-tests-1.18
├── ...
└── pom.xml

There are four primary components:

  • commandapi-bukkit-test-impl. This is a collection of interfaces and templates for the commandapi-bukkit-test-impl-a.b.c modules
  • commandapi-bukkit-test-impl-a.b.c. This is an implementation of MockNMS, the primary wrapper for NMS specific to Minecraft version a.b.c
  • commandapi-bukkit-test-tests. This is a collection of tests to run
  • commandapi-bukkit-test-tests-a.b.c. This is a collection of tests to run specific to Minecraft version x.x.x that would otherwise be unable to test in commandapi-bukkit-test-tests

Developer's Note:

At the time of writing (12th Jan 2023) The testing matrix is still in very early development! commandapi-bukkit-test-impl doesn't exist yet! For now, use commandapi-bukkit-test-impl-1.19.2.

The order and profiles of running the testing matrix

  • commandapi-bukkit-test-tests should be built against the lowest version of Minecraft (1.13)
  • commandapi-bukkit-test-tests should be run against all versions (1.13 - 1.19.3) using the various Minecraft_a_b_c profiles
  • commandapi-bukkit-test-tests-a.b.c should ONLY be run against version a.b.c
  • commandapi-bukkit-test-tests-a.b.c and commandapi-bukkit-test-tests-d.e.f may have overlapping tests. This is fine and should be the only place in the repo with copy/pasta all over the place

Adding argument tests to the testing matrix

To figure out where this argument goes depends on the version (or versions) of Minecraft that this argument is compatible with. For arguments compatible with all Minecraft versions, start with commandapi-bukkit-test-impl and commandapi-bukkit-test-tests. Then follow these steps:

  • Create a class Argument<Name>Tests.java in dev.jorel.commandapi.test.arguments. For example, a ListArgument test needs to be under ArgumentListTests.java. It's probably easier to copy an existing file, such as ArgumentTimeTests.java
    • Make sure your class extends TestBase
    • Declare your setUp() and tearDown() methods and place those under a Setup comment
    • Declare your Tests comment and Suggestion tests comment
  • Write your tests. Depending on the test type, follow these guidelines

Execution tests

For execution tests (testing the command runs):

  • Declare them in a method executionTestWith<Name>Argument()
  • Declare one command per method
  • Add assertNoMoreResults(results) at the end if you've used Mut<> results = Mut.of() at the top

Suggestion tests

  • Declare them in a method suggestionTestWith<Name>Argument()