mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Merge branch '6.2.x'
This commit is contained in:
@@ -102,6 +102,20 @@ public interface TestContext extends AttributeAccessor, Serializable {
|
||||
|
||||
/**
|
||||
* Get the {@linkplain Class test class} for this test context.
|
||||
* <p>Since JUnit Jupiter 5.12, if the
|
||||
* {@link org.springframework.test.context.junit.jupiter.SpringExtension
|
||||
* SpringExtension} is used with a {@linkplain
|
||||
* org.junit.jupiter.api.extension.TestInstantiationAwareExtension.ExtensionContextScope#TEST_METHOD
|
||||
* test-method scoped} {@link org.junit.jupiter.api.extension.ExtensionContext
|
||||
* ExtensionContext}, the {@code Class} returned from this method may refer
|
||||
* to the test class for the current {@linkplain #getTestMethod() test method},
|
||||
* which may be a {@link org.junit.jupiter.api.Nested @Nested} test class
|
||||
* within the class for the {@linkplain #getTestInstance() test instance}.
|
||||
* Thus, if you need consistent access to the class for the current test
|
||||
* instance within an implementation of
|
||||
* {@link TestExecutionListener#prepareTestInstance(TestContext)}, you should
|
||||
* invoke {@code testContext.getTestInstance().getClass()} instead of
|
||||
* {@code testContext.getTestClass()}.
|
||||
* @return the test class (never {@code null})
|
||||
*/
|
||||
Class<?> getTestClass();
|
||||
|
||||
@@ -150,6 +150,19 @@ public interface TestExecutionListener {
|
||||
* {@link org.springframework.test.context.junit4.rules.SpringMethodRule
|
||||
* SpringMethodRule}). In any case, this method must be called prior to any
|
||||
* framework-specific lifecycle callbacks.
|
||||
* <p>Since JUnit Jupiter 5.12, if the
|
||||
* {@link org.springframework.test.context.junit.jupiter.SpringExtension
|
||||
* SpringExtension} is used with a {@linkplain
|
||||
* org.junit.jupiter.api.extension.TestInstantiationAwareExtension.ExtensionContextScope#TEST_METHOD
|
||||
* test-method scoped} {@link org.junit.jupiter.api.extension.ExtensionContext
|
||||
* ExtensionContext}, the {@link Class} returned from
|
||||
* {@link TestContext#getTestClass()} may refer to the test class for the
|
||||
* current {@linkplain TestContext#getTestMethod() test method}, which may be
|
||||
* a {@link org.junit.jupiter.api.Nested @Nested} test class within the class
|
||||
* for the {@linkplain TestContext#getTestInstance() test instance}. Thus, if
|
||||
* you need consistent access to the class for the current test instance, you
|
||||
* should invoke {@code testContext.getTestInstance().getClass()} instead of
|
||||
* {@code testContext.getTestClass()}.
|
||||
* <p>See the {@linkplain TestExecutionListener class-level documentation}
|
||||
* for details on wrapping behavior for listeners.
|
||||
* <p>The default implementation is <em>empty</em>. Can be overridden by
|
||||
|
||||
Reference in New Issue
Block a user