Package org.approvej.spring
Record Class SpringTestContextsPrintFormat
java.lang.Object
java.lang.Record
org.approvej.spring.SpringTestContextsPrintFormat
- Record Components:
includeTestClasses- whether to list the test classes using each context
- All Implemented Interfaces:
org.approvej.print.PrintFormat<SpringTestContexts>
@NullMarked
public record SpringTestContextsPrintFormat(boolean includeTestClasses)
extends Record
implements org.approvej.print.PrintFormat<SpringTestContexts>
PrintFormat for SpringTestContexts that prints each distinct context with all
details relevant to Spring's context caching.
The contexts are sorted by their printed form, so adding or removing test classes does not reorder the output. The parent contexts of context hierarchies are printed as contexts of their own, as Spring caches them as well. For example:
- loader: SpringBootContextLoader
classes:
- com.example.Application
profiles:
- test
customizers:
- @MockitoBean com.example.PaymentClient field=paymentClient
- @SpringBootTest(webEnvironment=MOCK)
Usages of @DirtiesContext are listed with each context they cause to be started again,
as they slow down the test suite just like additional contexts.
Some details of unknown context customizers cannot be printed. If two distinct contexts are printed identically, both are marked with a note.
-
Field Summary
Fields inherited from interface org.approvej.print.PrintFormat
DEFAULT_FILENAME_EXTENSION -
Constructor Summary
ConstructorsConstructorDescriptionSpringTestContextsPrintFormat(boolean includeTestClasses) Creates an instance of aSpringTestContextsPrintFormatrecord class. -
Method Summary
Modifier and TypeMethodDescriptionCreates a newSpringTestContextsPrintFormatthat does not list the test classes, so adding a test class that uses an existing context does not change the output.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReturns the value of theincludeTestClassesrecord component.org.approvej.print.Printer<SpringTestContexts> printer()final StringtoString()Returns a string representation of this record class.Returns a copy of this that also lists the test classes using each context.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.approvej.print.PrintFormat
filenameExtension
-
Constructor Details
-
SpringTestContextsPrintFormat
public SpringTestContextsPrintFormat(boolean includeTestClasses) Creates an instance of aSpringTestContextsPrintFormatrecord class.- Parameters:
includeTestClasses- the value for theincludeTestClassesrecord component
-
-
Method Details
-
contextConfigurations
Creates a newSpringTestContextsPrintFormatthat does not list the test classes, so adding a test class that uses an existing context does not change the output.- Returns:
- a new
SpringTestContextsPrintFormat
-
withTestClasses
Returns a copy of this that also lists the test classes using each context.Note that this changes the output whenever a test class is added, removed, or renamed.
- Returns:
- a copy of this including the test classes
-
printer
- Specified by:
printerin interfaceorg.approvej.print.PrintFormat<SpringTestContexts>
-
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 with '=='. -
includeTestClasses
public boolean includeTestClasses()Returns the value of theincludeTestClassesrecord component.- Returns:
- the value of the
includeTestClassesrecord component
-