Class EventTest

java.lang.Object
net.minecraftforge.eventtest.internal.EventTest
Direct Known Subclasses:
EntityJoinedWorldTest, LivingMakeBrainEventTest

public abstract class EventTest extends Object
The basis of the Event regression testing framework. Allows each bootstrap event to be queried in turn to see whether the event passed. For gameplay events, a callback is set for when the respective event is fired. Test cases should be in a subclass of this, annotated with TestHolder. If the test is for an event that fires in Bootstrap, set the field in constructor. Register the event handler in the registerEvents method, which will be fired automatically. Use the pass / fail / error methods in this class to tell the Framework what the result of the test is.
Author:
Curle
  • Field Details

    • testResult

      protected EventTest.Result testResult
    • errorDetail

      protected String errorDetail
    • bootstrap

      protected boolean bootstrap
  • Constructor Details

    • EventTest

      public EventTest()
  • Method Details

    • getTestResult

      public String getTestResult()
      A summarised view of the test result. For passes: "PASS" For failures: "FAIL - ($errorDetail)"
      Returns:
      test result
    • getEnhancedDetail

      protected String getEnhancedDetail()
      Provide extra detail about the error. Pass-through of errorDetail is default, but some events require something more robust.
      Returns:
      information to be shown in case of a test failure
    • isBootstrap

      public boolean isBootstrap()
      Returns:
      whether or not this event should be monitored while the game is loading to the main menu.
    • registerEvents

      public abstract void registerEvents()
      Register event handlers for this event. Trade-off between "magic annotations" and verbosity should be evaluated.
    • fail

      protected void fail(String reason)
      Helper method - combines setting failure state with detail message.
      Parameters:
      reason - extra detail about why the failure occurred
    • pass

      protected void pass()
      Helper method - sets the test pass flag.
    • error

      protected void error(String reason)
      Helper method - combines setting error state with detail message.
      Parameters:
      reason - extra detail about why the error occured.