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.Dynamic
Nested classes/interfaces inherited from interface net.neoforged.testframework.DynamicTest
DynamicTest.EnabledListener
Nested classes/interfaces inherited from interface net.neoforged.testframework.Test
Test.EventListenerGroup, Test.Result, Test.Status, Test.Visuals
-
Field Summary
Modifier and TypeFieldDescriptionprivate final List<DynamicTest.EnabledListener>
private final Supplier<Test.EventListenerGroup>
private boolean
private final List<Consumer<ExtendedGameTestHelper>>
Fields inherited from class net.neoforged.testframework.impl.test.AbstractTest
enabledByDefault, framework, gameTestData, groups, id, listeners, visuals
-
Constructor Summary
-
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.void
Marks this test as failed.Returns the framework this test is linked to.protected String
gameTestTemplate
(GameTest gameTest) boolean
Returns if this test is currently running as a GameTest.void
This method is called when this test is disabled.void
onEnabled
(Test.EventListenerGroup buses) This method is called when this test is enabled.void
onGameTest
(Consumer<ExtendedGameTestHelper> consumer) Registers a listener to run when the GameTest version of this test is run.protected void
onGameTest
(GameTestHelper helper) void
pass()
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
.void
whenDisabled
(Runnable whenDisabled) Registers a listener to run when this test is disabled.void
whenEnabled
(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, visuals
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.testframework.DynamicTest
registerGameTestTemplate, registerGameTestTemplate, requestConfirmation, status, updateStatus
Methods 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:DynamicTest
Returns the framework this test is linked to.- Specified by:
framework
in interfaceDynamicTest
- Returns:
- the framework this test is linked to
-
whenEnabled
Description copied from interface:DynamicTest
Registers a listener to run when this test is enabled.- Specified by:
whenEnabled
in interfaceDynamicTest
- Parameters:
whenEnabled
- the listener
-
eventListeners
Description copied from interface:DynamicTest
Returns a listener group used to subscribe to events when the test is enabled.- Specified by:
eventListeners
in interfaceDynamicTest
- Returns:
- a listener group used to subscribe to events when the test is enabled
- See Also:
-
whenDisabled
Description copied from interface:DynamicTest
Registers a listener to run when this test is disabled.- Specified by:
whenDisabled
in interfaceDynamicTest
- Parameters:
whenDisabled
- the listener
-
onEnabled
Description copied from interface:Test
This method is called when this test is enabled.- Specified by:
onEnabled
in interfaceTest
- Overrides:
onEnabled
in 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:Test
This method is called when this test is disabled.- Specified by:
onDisabled
in interfaceTest
- Overrides:
onDisabled
in classAbstractTest
-
onGameTest
Description copied from interface:DynamicTest
Registers a listener to run when the GameTest version of this test is run.- Specified by:
onGameTest
in interfaceDynamicTest
- Parameters:
consumer
- the listener
-
registrationHelper
Description copied from interface:DynamicTest
Returns a new registration helper with the givenmodId
.- Specified by:
registrationHelper
in interfaceDynamicTest
- Returns:
- a new registration helper with the given
modId
-
registrationHelper
Description copied from interface:DynamicTest
Returns a new registration helper with a computed mod ID.- Specified by:
registrationHelper
in interfaceDynamicTest
- Returns:
- a new registration helper with a computed mod ID
-
createModId
Description copied from interface:DynamicTest
Returns a computed mod id based on this test's ID.- Specified by:
createModId
in interfaceDynamicTest
- Returns:
- a computed mod id based on this test's ID
-
gameTestTemplate
- Overrides:
gameTestTemplate
in classAbstractTest
-
onGameTest
- Overrides:
onGameTest
in classAbstractTest
-
isDuringGameTest
public boolean isDuringGameTest()Description copied from interface:DynamicTest
Returns if this test is currently running as a GameTest.- Specified by:
isDuringGameTest
in interfaceDynamicTest
- Returns:
- if this test is currently running as a GameTest
-
fail
Description copied from interface:DynamicTest
Marks this test as failed.- Specified by:
fail
in interfaceDynamicTest
- Overrides:
fail
in classAbstractTest
- 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 interfaceDynamicTest
- Overrides:
pass
in classAbstractTest
-