Record Class SpringTestContext

java.lang.Object
java.lang.Record
org.approvej.spring.SpringTestContext
Record Components:
configuration - the MergedContextConfiguration identifying the context
testClasses - the test classes directly using the context, sorted by name; empty for a parent context that is only used in a context hierarchy
dirtiesContextUsages - the DirtiesContextUsages causing the context to be started again, including those of test classes using a child context

@NullMarked public record SpringTestContext(org.springframework.test.context.MergedContextConfiguration configuration, List<Class<?>> testClasses, List<DirtiesContextUsage> dirtiesContextUsages) extends Record
A distinct Spring test application context and the test classes sharing it.

Spring caches test application contexts by their MergedContextConfiguration. All test classes with an equal configuration share one context, each additional distinct configuration causes another context to be started.

  • Constructor Details

    • SpringTestContext

      public SpringTestContext(org.springframework.test.context.MergedContextConfiguration configuration, List<Class<?>> testClasses, List<DirtiesContextUsage> dirtiesContextUsages)
      Creates a new SpringTestContext.
      Parameters:
      configuration - the MergedContextConfiguration identifying the context
      testClasses - the test classes directly using the context
      dirtiesContextUsages - the DirtiesContextUsages causing the context to be started again
  • Method Details

    • 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.
    • configuration

      public org.springframework.test.context.MergedContextConfiguration configuration()
      Returns the value of the configuration record component.
      Returns:
      the value of the configuration record component
    • testClasses

      public List<Class<?>> testClasses()
      Returns the value of the testClasses record component.
      Returns:
      the value of the testClasses record component
    • dirtiesContextUsages

      public List<DirtiesContextUsage> dirtiesContextUsages()
      Returns the value of the dirtiesContextUsages record component.
      Returns:
      the value of the dirtiesContextUsages record component