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 with FPTest)
beforeEach - the method annotated with FPBeforeEach to run before each test
afterEach - the method annotated with FPAfterEach to run after each test
testMethods - the list of test methods annotated with FPTest

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
    Constructor
    Description
    FPTestClass(Class<?> testClass, Method beforeEach, Method afterEach, List<Method> testMethods)
    Creates an instance of a FPTestClass record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the afterEach record component.
    Returns the value of the beforeEach record component.
    Generates a display name for a given test method, incorporating annotation details if present.
    final boolean
    Indicates whether some other object is "equal to" this one.
    fromClass(Class<?> testClass)
    Creates an instance of FPTestClass by inspecting the provided test class for methods annotated with FPTest, FPBeforeEach, and FPAfterEach annotations.
    final int
    Returns a hash code value for this object.
    boolean
    runTests(org.bukkit.entity.Player player)
    Runs the test methods belonging to the test class, performing any necessary setup and teardown operations.
    Returns the value of the testClass record component.
    Returns the value of the testMethods record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FPTestClass

      public FPTestClass(Class<?> testClass, Method beforeEach, Method afterEach, List<Method> testMethods)
      Creates an instance of a FPTestClass record class.
      Parameters:
      testClass - the value for the testClass record component
      beforeEach - the value for the beforeEach record component
      afterEach - the value for the afterEach record component
      testMethods - the value for the testMethods record component
  • Method Details

    • fromClass

      public static FPTestClass fromClass(Class<?> testClass)
      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

      public String displayName(Method m)
      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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • testClass

      public Class<?> testClass()
      Returns the value of the testClass record component.
      Returns:
      the value of the testClass record component
    • beforeEach

      public Method beforeEach()
      Returns the value of the beforeEach record component.
      Returns:
      the value of the beforeEach record component
    • afterEach

      public Method afterEach()
      Returns the value of the afterEach record component.
      Returns:
      the value of the afterEach record component
    • testMethods

      public List<Method> testMethods()
      Returns the value of the testMethods record component.
      Returns:
      the value of the testMethods record component