-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add example for a test base class
- Loading branch information
Showing
4 changed files
with
25 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# add your default configuration properties here | ||
# add your configuration properties here |
20 changes: 1 addition & 19 deletions
20
src/test/java/net/silthus/template/TemplatePluginTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,14 @@ | ||
package net.silthus.template; | ||
|
||
import be.seeseemelk.mockbukkit.MockBukkit; | ||
import be.seeseemelk.mockbukkit.ServerMock; | ||
import org.bukkit.event.player.PlayerJoinEvent; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class TemplatePluginTests { | ||
|
||
private ServerMock server; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
server = MockBukkit.mock(); | ||
MockBukkit.load(TemplatePlugin.class); | ||
} | ||
public class TemplatePluginTests extends TestBase { | ||
|
||
@Test | ||
public void shouldFirePlayerJoinEvent() { | ||
|
||
server.addPlayer(); | ||
|
||
server.getPluginManager().assertEventFired(PlayerJoinEvent.class); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
MockBukkit.unmock(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net.silthus.template; | ||
|
||
import be.seeseemelk.mockbukkit.MockBukkit; | ||
import be.seeseemelk.mockbukkit.ServerMock; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
public abstract class TestBase { | ||
|
||
protected ServerMock server; | ||
protected TemplatePlugin plugin; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
server = MockBukkit.mock(); | ||
plugin = MockBukkit.load(TemplatePlugin.class); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
MockBukkit.unmock(); | ||
} | ||
} |