About 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
@Test
(name
="teleport only player with op") publicvoid shouldBeTeleported
(){ //Arrange Player playerJoe
= addPlayer
("joe"); Player playerMike
= addPlayer
("mike");
//Assert assertThatEvent
(PlayerTeleportEvent.
class) .
wasInvoked(Times.
once())//since only one player has OP event will be triggered once .
validate();