Class ScenarioTestHelper

java.lang.Object
fr.fidorial.testing.ScenarioTestHelper

public final class ScenarioTestHelper extends Object
The toolbox handed to a ScenarioTest method: its world, mock players, assertions and sequences.
Since:
0.1.0
  • Method Details

    • world

      public World world()
      Returns the world the test runs in.
      Returns:
      the world the test runs in
      Since:
      0.1.0
    • summonPlayer

      public Player summonPlayer(String name, Location location, GameMode gameMode)
      Summons a mock player into world().
      Parameters:
      name - the player name
      location - where to spawn the player
      gameMode - the game mode of the player
      Returns:
      the summoned player
      Since:
      0.1.0
      API Note:
      the player is automatically despawned upon test completion, regardless of its result.
    • summonPlayer

      public Player summonPlayer(String name, World world, Location location, GameMode gameMode)
      Summons a mock player into the specified world.
      Parameters:
      name - the player name
      world - the world to spawn the player in
      location - where to spawn the player
      gameMode - the game mode of the player
      Returns:
      the summoned player
      Since:
      0.1.0
      API Note:
      the player is automatically despawned upon test completion, regardless of its result.
    • fail

      public void fail(String reason)
      Fails the test right away.
      Parameters:
      reason - the failure message
      Throws:
      RuntimeException - always, to abort the test
      Since:
      0.1.0
    • assertTrue

      public void assertTrue(boolean condition, String messageIfFalse)
      Fails the test unless a condition holds.
      Parameters:
      condition - the condition to check
      messageIfFalse - the failure message
      Since:
      0.1.0
    • assertBlockAt

      public void assertBlockAt(BlockPos pos, Key expected)
      Fails the test unless a block of the expected type sits at a position.
      Parameters:
      pos - the block position
      expected - the expected block key; minecraft:air matches any kind of air
      Since:
      0.1.0
    • sequence

      public ScenarioTestSequence.Builder sequence()
      Starts building the sequence of steps of this test; the test passes once the built sequence completes.
      Returns:
      a sequence builder; call build() on it before the method returns
      Since:
      0.1.0