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
-
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.testframework.impl.test.AbstractTest
AbstractTest.AnnotationHolder, AbstractTest.DynamicNested classes/interfaces inherited from interface net.neoforged.testframework.DynamicTest
DynamicTest.EnabledListenerNested classes/interfaces inherited from interface net.neoforged.testframework.Test
Test.EventListenerGroup, Test.Result, Test.Status, Test.Visuals -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<DynamicTest.EnabledListener> private final Supplier<Test.EventListenerGroup> private booleanprivate final List<Consumer<GameTestHelper>> Fields inherited from class net.neoforged.testframework.impl.test.AbstractTest
enabledByDefault, framework, gameTestData, groups, id, listeners, visuals -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a computed mod id based on this test's ID.Returns a listener group used to subscribe to events when the test is enabled.voidMarks this test as failed.Returns the framework this test is linked to.protected StringgameTestTemplate(GameTest gameTest) booleanReturns if this test is currently running as a GameTest.voidThis method is called when this test is disabled.voidonEnabled(Test.EventListenerGroup buses) This method is called when this test is enabled.<T extends GameTestHelper>
voidonGameTest(Class<T> helperType, Consumer<T> consumer) Registers a listener to run when the GameTest version of this test is run.voidonGameTest(Consumer<ExtendedGameTestHelper> consumer) Registers a listener to run when the GameTest version of this test is run.protected voidonGameTest(GameTestHelper helper) private <T extends GameTestHelper>
voidonGameTest(GameTestHelperFactory<T> factory, Consumer<T> consumer) voidpass()Marks this test as passed.Returns a new registration helper with a computed mod ID.registrationHelper(String modId) Returns a new registration helper with the givenmodId.voidwhenDisabled(Runnable whenDisabled) Registers a listener to run when this test is disabled.voidwhenEnabled(DynamicTest.EnabledListener whenEnabled) Registers a listener to run when this test is enabled.Methods inherited from class net.neoforged.testframework.impl.test.AbstractTest
asGameTest, configureFrom, configureGameTest, enable, enabledByDefault, groups, id, init, isEnabled, listeners, logger, requestConfirmation, status, updateStatus, visualsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.testframework.DynamicTest
registerGameTestTemplate, registerGameTestTemplate, requestConfirmation, status, updateStatusMethods inherited from interface net.neoforged.testframework.Test
asGameTest, enabledByDefault, groups, id, init, listeners, resolveAll, resolveAsStream, visuals
-
Field Details
-
enabledListeners
-
eventListeners
-
disabledListeners
-
onGameTest
-
isDuringGameTest
private boolean isDuringGameTest
-
-
Constructor Details
-
Dynamic
public Dynamic()
-
-
Method Details
-
framework
Description copied from interface:DynamicTestReturns the framework this test is linked to.- Specified by:
frameworkin interfaceDynamicTest- Returns:
- the framework this test is linked to
-
whenEnabled
Description copied from interface:DynamicTestRegisters a listener to run when this test is enabled.- Specified by:
whenEnabledin interfaceDynamicTest- Parameters:
whenEnabled- the listener
-
eventListeners
Description copied from interface:DynamicTestReturns a listener group used to subscribe to events when the test is enabled.- Specified by:
eventListenersin interfaceDynamicTest- Returns:
- a listener group used to subscribe to events when the test is enabled
- See Also:
-
whenDisabled
Description copied from interface:DynamicTestRegisters a listener to run when this test is disabled.- Specified by:
whenDisabledin interfaceDynamicTest- Parameters:
whenDisabled- the listener
-
onEnabled
Description copied from interface:TestThis method is called when this test is enabled.- Specified by:
onEnabledin interfaceTest- Overrides:
onEnabledin classAbstractTest- Parameters:
buses- a collector for event listeners. Prefer using this listener instead of the casualIEventBus.addListener(Consumer)orIEventBus.register(Object), as the collector will automatically unregister listeners when the test is disabled
-
onDisabled
public void onDisabled()Description copied from interface:TestThis method is called when this test is disabled.- Specified by:
onDisabledin interfaceTest- Overrides:
onDisabledin classAbstractTest
-
onGameTest
Description copied from interface:DynamicTestRegisters a listener to run when the GameTest version of this test is run.- Specified by:
onGameTestin interfaceDynamicTest- Parameters:
consumer- the listener
-
onGameTest
Description copied from interface:DynamicTestRegisters a listener to run when the GameTest version of this test is run.- Specified by:
onGameTestin interfaceDynamicTest- Parameters:
helperType- the type to use for the helperconsumer- the listener
-
onGameTest
private <T extends GameTestHelper> void onGameTest(GameTestHelperFactory<T> factory, Consumer<T> consumer) -
registrationHelper
Description copied from interface:DynamicTestReturns a new registration helper with the givenmodId.- Specified by:
registrationHelperin interfaceDynamicTest- Returns:
- a new registration helper with the given
modId
-
registrationHelper
Description copied from interface:DynamicTestReturns a new registration helper with a computed mod ID.- Specified by:
registrationHelperin interfaceDynamicTest- Returns:
- a new registration helper with a computed mod ID
-
createModId
Description copied from interface:DynamicTestReturns a computed mod id based on this test's ID.- Specified by:
createModIdin interfaceDynamicTest- Returns:
- a computed mod id based on this test's ID
-
gameTestTemplate
- Overrides:
gameTestTemplatein classAbstractTest
-
onGameTest
- Overrides:
onGameTestin classAbstractTest
-
isDuringGameTest
public boolean isDuringGameTest()Description copied from interface:DynamicTestReturns if this test is currently running as a GameTest.- Specified by:
isDuringGameTestin interfaceDynamicTest- Returns:
- if this test is currently running as a GameTest
-
fail
Description copied from interface:DynamicTestMarks this test as failed.- Specified by:
failin interfaceDynamicTest- Overrides:
failin classAbstractTest- Parameters:
message- additional information explaining why the test failed
-
pass
public void pass()Description copied from interface:DynamicTestMarks this test as passed.- Specified by:
passin interfaceDynamicTest- Overrides:
passin classAbstractTest
-