Getting Started
In order to use MockBukkit, you first have to integrate it into your build tool. You will also need to know which version of MockBukkit to use. MockBukkit version numbering can be a little bit confusing. The most important thing to remember is that each version of MockBukkit is named after the version of Bukkit it implements, followed by the version number of MockBukkit itself.
For instance: MockBukkit-v1.21 v3.107.0 is the 3.107.0 release of MockBukkit, targeting plugins build for Minecraft 1.21. The latest stable version can always be found on Maven Central.
Gradle
If you are using Gradle, you will need to setup your build.gradle file to enable
unit testing.
Dependencies
To enable unit testing, all you need to do is add the JUnit dependency and the correct MockBukkit dependency. Here is an example which adds support for JUnit 5.9.3 and MockBukkit-v1.20:3.0.0
Groovy DSL
This is how you add the dependencies in Groovy DSL
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.0'
testImplementation 'com.github.seeseemelk:MockBukkit-v1.21:3.107.0'
}
Kotlin DSL
This is how you add the dependencies in Kotlin DSL
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.11.0")
testImplementation("com.github.seeseemelk:MockBukkit-v1.21:3.107.0")
}
Running
When this has been added, you can run your tests using the test task. For Windows, running the following command will execute the tests
gradlew.bat test
On Linux and macOS, use the following command
./gradlew test
Maven
For people that use Maven instead of Gradle can also use MockBukkit by adding it
to their pom.xml.
To do so, both JUnit and MockBukkit have to be added to your dependencies
1<dependencies>
2 <dependency>
3 <groupId>org.junit.jupiter</groupId>
4 <artifactId>junit-jupiter</artifactId>
5 <version>5.11.0</version>
6 <scope>test</scope>
7 </dependency>
8 <dependency>
9 <groupId>com.github.seeseemelk</groupId>
10 <artifactId>MockBukkit-v1.20</artifactId>
11 <version>3.107.0</version>
12 <scope>test</scope>
13 </dependency>
14 <!-- Add your other dependencies here -->
15</dependencies>
16
17<build>
18 <pluginManagement>
19 <plugins>
20 <plugin>
21 <artifactId>maven-surefire-plugin</artifactId>
22 </plugin>
23 </plugins>
24 </pluginManagement>
25</build>
Running
After having modified your pom.xml, you can run the unit tests as follows
mvn test