Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.onelitefeather.cygnus;

import net.minestom.server.entity.Player;
import net.minestom.server.network.PlayerProvider;
import net.minestom.testing.Env;
import net.minestom.testing.extension.MicrotusExtension;
import net.onelitefeather.cygnus.player.CygnusPlayer;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* The class is a small utility class which overwrites the given {@link PlayerProvider} from the test environment to use the {@link CygnusPlayer} instead of the default {@link Player}.
* This allows us to test the stamina system and other player related features without having to create a new player provider for each test class.
*
* @author Joltra
* @version 1.0.0
* @since 2.3.0
*/
@ExtendWith(MicrotusExtension.class)
public abstract class CygnusPlayerTestBase {

@BeforeAll
static void init(Env env) {
env.process().connection().setPlayerProvider(CygnusPlayer::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
import net.minestom.server.entity.Player;
import net.minestom.server.instance.Instance;
import net.minestom.testing.Env;
import net.minestom.testing.extension.MicrotusExtension;
import net.onelitefeather.cygnus.CygnusPlayerTestBase;
import net.onelitefeather.cygnus.player.CygnusPlayer;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import static org.junit.jupiter.api.Assertions.*;

@Disabled("The Minestom framework doesn't support custom player implementations in tests")
@ExtendWith(MicrotusExtension.class)
class StaminaFactoryTest {
class StaminaFactoryTest extends CygnusPlayerTestBase {

private static Instance instance;
private static Player player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
import net.minestom.server.entity.Player;
import net.minestom.server.instance.Instance;
import net.minestom.testing.Env;
import net.minestom.testing.extension.MicrotusExtension;
import net.onelitefeather.cygnus.CygnusPlayerTestBase;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import static org.junit.jupiter.api.Assertions.*;

@Disabled("The Minestom framework doesn't support custom player implementations in tests")
@ExtendWith(MicrotusExtension.class)
class StaminaServiceTest {
class StaminaServiceTest extends CygnusPlayerTestBase {

private static StaminaService staminaService;

Expand Down