All Projects β†’ seeseemelk β†’ Mockbukkit

seeseemelk / Mockbukkit

Licence: mit
MockBukkit is a mocking framework for bukkit to allow the easy unit testing of Bukkit plugins.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Mockbukkit

Worldedit
πŸ—ΊοΈ Minecraft map editor and mod
Stars: ✭ 2,288 (+1130.11%)
Mutual labels:  hacktoberfest, spigot, bukkit
Viabackwards
Allows the connection of older clients to newer server versions for Minecraft servers.
Stars: ✭ 135 (-27.42%)
Mutual labels:  hacktoberfest, spigot, bukkit
Skript
Skript is a Bukkit plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
Stars: ✭ 458 (+146.24%)
Mutual labels:  hacktoberfest, spigot, bukkit
Cardboard
The Bukkit/Spigot/Paper API implementation for Fabric
Stars: ✭ 220 (+18.28%)
Mutual labels:  hacktoberfest, spigot, bukkit
Slimefun4
Slimefun 4 - A unique Spigot/Paper plugin that looks and feels like a modpack. We've been giving you backpacks, jetpacks, reactors and much more since 2013.
Stars: ✭ 369 (+98.39%)
Mutual labels:  hacktoberfest, spigot, bukkit
Yatopia
The Most Powerful and Feature Rich Minecraft Server Software!
Stars: ✭ 408 (+119.35%)
Mutual labels:  hacktoberfest, spigot, bukkit
Viaversion
Allows the connection of newer clients to older server versions for Minecraft servers.
Stars: ✭ 463 (+148.92%)
Mutual labels:  hacktoberfest, spigot, bukkit
Catserver
Spiritual inheritance of mcpc+/thermos/Cauldron, full support spigot/sponge/forge/bukkit/paper API
Stars: ✭ 127 (-31.72%)
Mutual labels:  spigot, bukkit
Serverlistplus
A flexible Minecraft plugin to customize the appearance of your server in the server list
Stars: ✭ 127 (-31.72%)
Mutual labels:  spigot, bukkit
Titlemanager
Adds hovering titles, actionbar titles, tabmenu titles and a scoreboard sidebar to your Minecraft 1.8 - 1.16 server.
Stars: ✭ 133 (-28.49%)
Mutual labels:  spigot, bukkit
Mobarena
MobArena plugin for Minecraft
Stars: ✭ 147 (-20.97%)
Mutual labels:  spigot, bukkit
Cloudnet V3
CloudNet v3 is the next generation of Minecraft Java and Bedrock cloud systems
Stars: ✭ 124 (-33.33%)
Mutual labels:  hacktoberfest, spigot
Betonquest
An advanced and powerful quest scripting plugin for Minecraft. Features built-in RPG style conversations and integration for over 25 other plugins.
Stars: ✭ 121 (-34.95%)
Mutual labels:  spigot, bukkit
Stryker4s
Mutation testing for Scala. Work in progress...
Stars: ✭ 118 (-36.56%)
Mutual labels:  hacktoberfest, unit-testing
Slime World Manager
A Spigot plugin that implements the Slime Region Format.
Stars: ✭ 118 (-36.56%)
Mutual labels:  spigot, bukkit
Commandbook
General and administrative commands
Stars: ✭ 139 (-25.27%)
Mutual labels:  spigot, bukkit
Android Client
An android client for the MifosX platform
Stars: ✭ 150 (-19.35%)
Mutual labels:  hacktoberfest, unit-testing
Lagmonitor
Monitor performance of your Minecraft server. Similar to VisualVM and Java Mission Control.
Stars: ✭ 147 (-20.97%)
Mutual labels:  spigot, bukkit
Chestshop 3
ChestShop - the chest & sign shop plugin for Minecraft Servers running Bukkit/Spigot/Paper
Stars: ✭ 158 (-15.05%)
Mutual labels:  spigot, bukkit
Item Nbt Api
Add custom NBT tags to Items/Tiles/Entities without NMS!
Stars: ✭ 163 (-12.37%)
Mutual labels:  spigot, bukkit

Build Status Documentation Status Maven Central Maintainability Test Coverage


MockBukkit logo

MockBukkit is a framework that makes the unit testing of Bukkit plugins a whole lot easier. It aims to be provide complete mock implementation of CraftBukkit that can be completely controlled from a unit test.

πŸ“„ Table of contents

  1. Usage
  2. Features
  3. Troubleshooting (My tests are being skipped)
  4. Discord server
  5. Examples (See MockBukkit in action)

πŸ” Usage

MockBukkit can easily be included in your project using either Maven or gradle.

Adding MockBukkit via gradle

MockBukkit can easily be included in gradle using mavenCentral.

repositories {
	mavenCentral()
	maven { url 'https://hub.spigotmc.org/nexus/content/repositories/public/' }
}

dependencies {
	testImplementation 'com.github.seeseemelk:MockBukkit-v1.16:0.25.0'
}

Note: use v1.13-SNAPSHOT to test a Bukkit 1.13 plugin or any other version if the branch exists. These branches will not be receiving patches actively, but any issues will be resolved and any pull requests on them will be accepted. This is because backporting every single patch on every branch is incredibely time consuming and slows down the development of Mockbukkit.

If you prefer to always have the latest Git version or need a specific commit/branch, you can always use JitPack as your maven repository:

repositories {
	maven { url 'https://jitpack.io' }
}

dependencies {
	implementation 'com.github.seeseemelk:MockBukkit:v1.16-SNAPSHOT'
}

Adding MockBukkit via Maven

MockBukkit can be included by adding the dependency to your pom.xml.
You won't need to add any additional repositories since MockBukkit is served via maven-central. Make sure to update the version as necessary.

<dependencies>
  <dependency>
    <groupId>com.github.seeseemelk</groupId>
    <artifactId>MockBukkit-v1.16</artifactId>
    <version>0.25.0</version>
    <scope>test</scope>
  </dependency>
</dependencies>

Note: use v1.13-SNAPSHOT to test a Bukkit 1.13 plugin or any other version if the branch exists. These branches will not be receiving patches actively, but any issues will be resolved and any pull requests on them will be accepted. This is because backporting every single patch on every branch is incredibely time consuming and slows down the development of Mockbukkit.

The scope test is important here since you are likely to only be using MockBukkit during the test stage of your Maven lifecycle and not in your final product.

Using MockBukkit

In order to use MockBukkit the plugin to be tested needs an extra constructor and it has to be initialised before each test. The plugin will need both a default constructor and an extra one that will call a super constructor. Your plugins constructor will look like this if your plugin was called MyPlugin.

public class MyPlugin extends JavaPlugin
{
    public MyPlugin()
    {
        super();
    }

    protected MyPlugin(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file)
    {
        super(loader, description, dataFolder, file);
    }
}

The plugin is now ready to be tested by MockBukkit. A plugin can be loaded in this initialiser block.

private ServerMock server;
private MyPlugin plugin;

@Before
public void setUp()
{
    server = MockBukkit.mock();
    plugin = (MyPlugin) MockBukkit.load(MyPlugin.class);
}

@After
public void tearDown()
{
    MockBukkit.unmock();
}

✨ Features

Mock Plugins

MockBukkit contains several functions that make the unit testing of Bukkit plugins a lot easier.

It is possible to create a mock plugin. This is useful when the plugin you are testing may be looking at other loaded plugins. The following piece of code creates a placeholder plugin that extends JavaPlugin.

MockPlugin plugin = MockBukkit.createMockPlugin()

Mock Players

MockBukkit makes it easy to create several mock players to use in unit testing. By running server.setPlayers(int numberOfPlayers) one can set the number of online players. From then on it's possible to get a certain player using server.getPlayer(int i).

An even easier way to create a player on the fly is by simply using

PlayerMock player = server.addPlayer();

A mock player also supports several simulated actions, such as damaging a block or even breaking it. This will fire all the required events and will remove the block if the events weren't cancelled.

Block block = ...;
player.simulateBlockBreak(block);

Mock Worlds

Another feature is the easy creation of mock worlds. One can make a superflat world using one simple command:

World world = new WorldMock(Material material, int heightUntilAir)

Using Material.DIRT and 3 as heightUntilAir will create a superflat world with a height of a 128. At y=0 everything will be Material.BEDROCK, and from 1 until 3 (inclusive) will be Material.DIRT and everything else will be Material.AIR. Each block is created the moment it is first accessed, so if only one block is only ever touched only one block will ever be created in-memory.

❓ My tests are being skipped!? (UnimplementedOperationException)

Sometimes your code may use a method that is not yet implemented in MockBukkit. When this happens MockBukkit will, instead of returning placeholder values, throw an UnimplementedOperationException. These exception extends AssumationException and will cause the test to be skipped.

These exceptions should just be ignored, though pull requests that add functionality to MockBukkit are always welcome! If you don't want to add the required methods yourself you can also request the method on the issues page.

🎧 Discord Server

You can also find us on discord by the way! If you need any help with MockBukkit or have a question regarding this project, feel free to join and connect with other members of the community.

Discord Invite

πŸŽ‰ Examples (See MockBukkit in action)

Several projects have utilized MockBukkit for their needs already. If you want to see some projects that are using MockBukkit right now, feel free to take a peak:

You can also have a look at our documentation where we outline various examples and tricks on how to use MockBukkit already: https://mockbukkit.readthedocs.io/en/latest/index.html

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].