Class AbstractTest.Dynamic

java.lang.Object
net.neoforged.testframework.impl.test.AbstractTest
net.neoforged.testframework.impl.test.AbstractTest.Dynamic
All Implemented Interfaces:
DynamicTest, Groupable, Test
Direct Known Subclasses:
MethodBasedEventTest, MethodBasedGameTestTest, MethodBasedTest
Enclosing class:
AbstractTest

@ParametersAreNonnullByDefault public abstract static class AbstractTest.Dynamic extends AbstractTest implements DynamicTest
  • Field Details

  • Constructor Details

    • Dynamic

      public Dynamic()
  • Method Details

    • framework

      public TestFramework framework()
      Description copied from interface: DynamicTest
      Returns the framework this test is linked to.
      Specified by:
      framework in interface DynamicTest
      Returns:
      the framework this test is linked to
    • whenEnabled

      public void whenEnabled(DynamicTest.EnabledListener whenEnabled)
      Description copied from interface: DynamicTest
      Registers a listener to run when this test is enabled.
      Specified by:
      whenEnabled in interface DynamicTest
      Parameters:
      whenEnabled - the listener
    • eventListeners

      public Test.EventListenerGroup eventListeners()
      Description copied from interface: DynamicTest
      Returns a listener group used to subscribe to events when the test is enabled.
      Specified by:
      eventListeners in interface DynamicTest
      Returns:
      a listener group used to subscribe to events when the test is enabled
      See Also:
    • whenDisabled

      public void whenDisabled(Runnable whenDisabled)
      Description copied from interface: DynamicTest
      Registers a listener to run when this test is disabled.
      Specified by:
      whenDisabled in interface DynamicTest
      Parameters:
      whenDisabled - the listener
    • onEnabled

      public void onEnabled(Test.EventListenerGroup buses)
      Description copied from interface: Test
      This method is called when this test is enabled.
      Specified by:
      onEnabled in interface Test
      Overrides:
      onEnabled in class AbstractTest
      Parameters:
      buses - a collector for event listeners. Prefer using this listener instead of the casual IEventBus.addListener(Consumer) or IEventBus.register(Object), as the collector will automatically unregister listeners when the test is disabled
    • onDisabled

      public void onDisabled()
      Description copied from interface: Test
      This method is called when this test is disabled.
      Specified by:
      onDisabled in interface Test
      Overrides:
      onDisabled in class AbstractTest
    • onGameTest

      public void onGameTest(Consumer<ExtendedGameTestHelper> consumer)
      Description copied from interface: DynamicTest
      Registers a listener to run when the GameTest version of this test is run.
      Specified by:
      onGameTest in interface DynamicTest
      Parameters:
      consumer - the listener
    • onGameTest

      public <T extends net.minecraft.gametest.framework.GameTestHelper> void onGameTest(Class<T> helperType, Consumer<T> consumer)
      Description copied from interface: DynamicTest
      Registers a listener to run when the GameTest version of this test is run.
      Specified by:
      onGameTest in interface DynamicTest
      Parameters:
      helperType - the type to use for the helper
      consumer - the listener
    • onGameTest

      private <T extends net.minecraft.gametest.framework.GameTestHelper> void onGameTest(GameTestHelperFactory<T> factory, Consumer<T> consumer)
    • registrationHelper

      public RegistrationHelper registrationHelper(String modId)
      Description copied from interface: DynamicTest
      Returns a new registration helper with the given modId.
      Specified by:
      registrationHelper in interface DynamicTest
      Returns:
      a new registration helper with the given modId
    • registrationHelper

      public RegistrationHelper registrationHelper()
      Description copied from interface: DynamicTest
      Returns a new registration helper with a computed mod ID.
      Specified by:
      registrationHelper in interface DynamicTest
      Returns:
      a new registration helper with a computed mod ID
    • createModId

      public String createModId()
      Description copied from interface: DynamicTest
      Returns a computed mod id based on this test's ID.
      Specified by:
      createModId in interface DynamicTest
      Returns:
      a computed mod id based on this test's ID
    • gameTestTemplate

      protected String gameTestTemplate(GameTest gameTest)
      Overrides:
      gameTestTemplate in class AbstractTest
    • onGameTest

      protected void onGameTest(net.minecraft.gametest.framework.GameTestHelper helper)
      Overrides:
      onGameTest in class AbstractTest
    • isDuringGameTest

      public boolean isDuringGameTest()
      Description copied from interface: DynamicTest
      Returns if this test is currently running as a GameTest.
      Specified by:
      isDuringGameTest in interface DynamicTest
      Returns:
      if this test is currently running as a GameTest
    • fail

      public void fail(String message)
      Description copied from interface: DynamicTest
      Marks this test as failed.
      Specified by:
      fail in interface DynamicTest
      Overrides:
      fail in class AbstractTest
      Parameters:
      message - additional information explaining why the test failed
    • pass

      public void pass()
      Description copied from interface: DynamicTest
      Marks this test as passed.
      Specified by:
      pass in interface DynamicTest
      Overrides:
      pass in class AbstractTest