Package de.oliver.fancylib.tests
Record Class FPTestClass
java.lang.Object
java.lang.Record
de.oliver.fancylib.tests.FPTestClass
- Record Components:
testClass- the test class to run tests for (must be annotated withFPTest)beforeEach- the method annotated withFPBeforeEachto run before each testafterEach- the method annotated withFPAfterEachto run after each testtestMethods- the list of test methods annotated withFPTest
public record FPTestClass(Class<?> testClass, Method beforeEach, Method afterEach, List<Method> testMethods)
extends Record
FPTestClass is a record that encapsulates information about a test class and its associated test methods.
This class supports running tests annotated with
FPTest.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theafterEachrecord component.Returns the value of thebeforeEachrecord component.Generates a display name for a given test method, incorporating annotation details if present.final booleanIndicates whether some other object is "equal to" this one.static FPTestClassCreates an instance of FPTestClass by inspecting the provided test class for methods annotated with FPTest, FPBeforeEach, and FPAfterEach annotations.final inthashCode()Returns a hash code value for this object.booleanrunTests(org.bukkit.entity.Player player) Runs the test methods belonging to the test class, performing any necessary setup and teardown operations.Class<?>Returns the value of thetestClassrecord component.Returns the value of thetestMethodsrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
FPTestClass
public FPTestClass(Class<?> testClass, Method beforeEach, Method afterEach, List<Method> testMethods) Creates an instance of aFPTestClassrecord class.- Parameters:
testClass- the value for thetestClassrecord componentbeforeEach- the value for thebeforeEachrecord componentafterEach- the value for theafterEachrecord componenttestMethods- the value for thetestMethodsrecord component
-
-
Method Details
-
fromClass
Creates an instance of FPTestClass by inspecting the provided test class for methods annotated with FPTest, FPBeforeEach, and FPAfterEach annotations. These methods are used to define the setup, teardown, and test methods for the class.- Parameters:
testClass- the class to be inspected for annotated methods- Returns:
- an instance of FPTestClass containing the test class and its annotated methods
-
runTests
public boolean runTests(org.bukkit.entity.Player player) Runs the test methods belonging to the test class, performing any necessary setup and teardown operations.- Parameters:
player- The player context to pass to the test methods.- Returns:
- true if all tests completed successfully, false if any test failed or an unexpected exception occurred.
-
displayName
Generates a display name for a given test method, incorporating annotation details if present.- Parameters:
m- the method for which to generate the display name- Returns:
- a display name that includes the test class and method name, and optionally the value of the FPTest annotation's name attribute if the annotation is present
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
testClass
Returns the value of thetestClassrecord component.- Returns:
- the value of the
testClassrecord component
-
beforeEach
Returns the value of thebeforeEachrecord component.- Returns:
- the value of the
beforeEachrecord component
-
afterEach
Returns the value of theafterEachrecord component.- Returns:
- the value of the
afterEachrecord component
-
testMethods
Returns the value of thetestMethodsrecord component.- Returns:
- the value of the
testMethodsrecord component
-