ModsJava
SITF - Spigot Integration Testing Framework
Java mod listed for Minecraft 1.17–1.19. Download on the author's site.
⬇ Download on SpigotAbout SITF
This is a tool designed for adding integration tests to spigot plugins. This library is designed to behave simillar to Junit so you will find a lot similarities.
What are Integration tests?
Integration tests are a type of software testing that checks how different components or modules of a system work together. In other words, they test the integration between different parts of the software to ensure that they function correctly and produce the expected results. For example, an integration test for a spigot plugin might test how the player interacts with Commands, Events, Permissions. Integration tests are important for detecting errors or bugs that may arise from the interaction of different components, and for ensuring that the system as a whole works correctly.
Why should I use it?
When code base of your plugin growing rapidly there is harder and harder
to test some funcionaliies manually. To make life easier you can write test code that tests your functionallity automatically.
How to use SITF?
In order to use framework, every class from your plugin which contains a test should extend the abstract class PluginTest. Additionaly by implementing PluginTestsSetup to your main plugin class
tests configuration may be changed
To run tests just put both SpigotTester.jar and your plugin to plugins
folder and run server. Console will display informations about each
test and when all will be done, report will be generated at
server/plugins/SpigotTester/report.jsonClick to expand...
Maven
Spoiler: Maven
HTML:
<repositories>
<repository>
<id>jitpack.io </id>
<url>https://jitpack.io </url>
</repository>
</repositories>
<dependency>
<groupId>com.github.jwdeveloper </groupId>
<artifactId>SpigotTester </artifactId>
<version>1.0.2-Release </version>
<scope>provided </scope>
</dependency>
<repository>
<id>jitpack.io </id>
<url>https://jitpack.io </url>
</repository>
</repositories>
<dependency>
<groupId>com.github.jwdeveloper </groupId>
<artifactId>SpigotTester </artifactId>
<version>1.0.2-Release </version>
<scope>provided </scope>
</dependency>
Example plugin main
Spoiler: Example plugin main
Code (Java):
public
final
class PluginMain
extends JavaPlugin
implements PluginTestsSetup
{
//Example class that is passed to tests as parameter
private CraftingManager craftingManager ;
@Override
public void onEnable ( ) {
// Plugin startup logic
craftingManager = new CraftingManager ( ) ;
}
//Here you can configure tests and inject parameters
@Override
public void onTestsSetup (TestsBuilder builder ) {
builder. addParameter (craftingManager ) ;
}
}
//Example class that is passed to tests as parameter
private CraftingManager craftingManager ;
@Override
public void onEnable ( ) {
// Plugin startup logic
craftingManager = new CraftingManager ( ) ;
}
//Here you can configure tests and inject parameters
@Override
public void onTestsSetup (TestsBuilder builder ) {
builder. addParameter (craftingManager ) ;
}
}
Example Test
Spoiler: Example plugin main
Code (Java):
public
class ExampleTests
extends PluginTest
{
@Test (name = "crafting permission test" )
public void shouldUseCrafting ( ) {
//Arrange
Player player = addPlayer ( "mike" ) ;
CraftingManager craftingManager = getParameter (CraftingManager. class ) ;
PermissionAttachment attachment = player. addAttachment (getPlugin ( ) ) ;
attachment. setPermission ( "crating", true ) ;
//Act
boolean result = craftingManager. canPlayerUseCrating (player ) ;
//Assert
assertThat (result ). shouldBeTrue ( ) ;
assertThatPlayer (player )
. hasName ( "mike" )
. hasPermission ( "crating" ) ;
}
@Test (name = "teleport only player with op" )
public void shouldBeTeleported ( ) {
//Arrange
Player playerJoe = addPlayer ( "joe" ) ;
Player playerMike = addPlayer ( "mike" ) ;
//Act
invokeCommand (playerJoe, "teleport " + playerJoe. getName ( ) + " 1 3 3" ) ;
playerMike. setOp ( true ) ;
invokeCommand (playerMike, "teleport " + playerMike. getName ( ) + " 1 2 3" ) ;
//Assert
assertThatEvent (PlayerTeleportEvent. class )
. wasInvoked (Times. once ( ) ) //since only one player has OP event will be triggered once
. validate ( ) ;
assertThatCommand ( "teleport" )
. wasInvoked (Times. once ( ) )
. byPlayer (playerJoe )
. validate ( ) ;
assertThatCommand ( "teleport" )
. wasInvoked (Times. once ( ) )
. byPlayer (playerMike )
. validate ( ) ;
}
}
@Test (name = "crafting permission test" )
public void shouldUseCrafting ( ) {
//Arrange
Player player = addPlayer ( "mike" ) ;
CraftingManager craftingManager = getParameter (CraftingManager. class ) ;
PermissionAttachment attachment = player. addAttachment (getPlugin ( ) ) ;
attachment. setPermission ( "crating", true ) ;
//Act
boolean result = craftingManager. canPlayerUseCrating (player ) ;
//Assert
assertThat (result ). shouldBeTrue ( ) ;
assertThatPlayer (player )
. hasName ( "mike" )
. hasPermission ( "crating" ) ;
}
@Test (name = "teleport only player with op" )
public void shouldBeTeleported ( ) {
//Arrange
Player playerJoe = addPlayer ( "joe" ) ;
Player playerMike = addPlayer ( "mike" ) ;
//Act
invokeCommand (playerJoe, "teleport " + playerJoe. getName ( ) + " 1 3 3" ) ;
playerMike. setOp ( true ) ;
invokeCommand (playerMike, "teleport " + playerMike. getName ( ) + " 1 2 3" ) ;
//Assert
assertThatEvent (PlayerTeleportEvent. class )
. wasInvoked (Times. once ( ) ) //since only one player has OP event will be triggered once
. validate ( ) ;
assertThatCommand ( "teleport" )
. wasInvoked (Times. once ( ) )
. byPlayer (playerJoe )
. validate ( ) ;
assertThatCommand ( "teleport" )
. wasInvoked (Times. once ( ) )
. byPlayer (playerMike )
. validate ( ) ;
}
}
Generated tests report
server/plugins/SpigotTester/report.json
Spoiler: Generated tests report
Code (Text):
{
"isPassed": true,
"reportId": "a7e47b6d-4165-4692-a286-b07404d37401",
"createdAt": "2023-02-17 15:11:35.4724659+01",
"serverVersion": "3638-Spigot-d90018e-7dcb59b (MC: 1.19.3)",
"spigotVersion": "1.19.3-R0.1-SNAPSHOT",
"spigotTesterVersion": "1.0.0-Release",
"plugins": [
{
"isPassed": true,
"pluginVersion": "1.0.0",
"pluginName": "ExamplePluginToTest",
"classResults": [
{
"className": "ExampleTests",
"classPackage": "io.github.jwdeveloper.spigot.exampleplugintotest",
"isIgnored": false,
"isPassed": true,
"testMethods": [
{
"name": "teleport only player with op",
"isPassed": true,
"executionTime": 26.0652,
"isIgnored": false,
"errorMessage": "",
"stackTrace": ""
},
{
"name": "crafting permission test",
"isPassed": true,
"executionTime": 18.7894,
"isIgnored": false,
"errorMessage": "",
"stackTrace": ""
}
]
}
]
}
]
}
"isPassed": true,
"reportId": "a7e47b6d-4165-4692-a286-b07404d37401",
"createdAt": "2023-02-17 15:11:35.4724659+01",
"serverVersion": "3638-Spigot-d90018e-7dcb59b (MC: 1.19.3)",
"spigotVersion": "1.19.3-R0.1-SNAPSHOT",
"spigotTesterVersion": "1.0.0-Release",
"plugins": [
{
"isPassed": true,
"pluginVersion": "1.0.0",
"pluginName": "ExamplePluginToTest",
"classResults": [
{
"className": "ExampleTests",
"classPackage": "io.github.jwdeveloper.spigot.exampleplugintotest",
"isIgnored": false,
"isPassed": true,
"testMethods": [
{
"name": "teleport only player with op",
"isPassed": true,
"executionTime": 26.0652,
"isIgnored": false,
"errorMessage": "",
"stackTrace": ""
},
{
"name": "crafting permission test",
"isPassed": true,
"executionTime": 18.7894,
"isIgnored": false,
"errorMessage": "",
"stackTrace": ""
}
]
}
]
}
]
}
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.17, 1.18, 1.19
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
SITF - Spigot Integration Testing Framework is a free Minecraft Java mod. Compatible with Minecraft 1.17, 1.18, 1.19. Downloaded 114 times (via Spigot). Download it and open it directly in the game.