You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/servlet/test/method.adoc
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,23 +49,22 @@ Before we can use Spring Security Test support, we must perform some setup. An e
49
49
.Java
50
50
[source,java,role="primary"]
51
51
----
52
-
@RunWith(SpringJUnit4ClassRunner.class) // <1>
52
+
@ExtendWith(SpringExtension.class) // <1>
53
53
@ContextConfiguration // <2>
54
54
public class WithMockUserTests {
55
55
----
56
56
57
57
.Kotlin
58
58
[source,kotlin,role="secondary"]
59
59
----
60
-
@RunWith(SpringJUnit4ClassRunner::class)
60
+
@ExtendWith(SpringExtension.class)
61
61
@ContextConfiguration
62
62
class WithMockUserTests {
63
63
----
64
-
====
65
64
66
65
This is a basic example of how to setup Spring Security Test. The highlights are:
67
66
68
-
<1> `@RunWith` instructs the spring-test module that it should create an `ApplicationContext`. This is no different than using the existing Spring Test support. For additional information, refer to the https://docs.spring.io/spring-framework/docs/4.0.x/spring-framework-reference/htmlsingle/#integration-testing-annotations-standard[Spring Reference]
67
+
<1> `@ExtendWith` instructs the spring-test module that it should create an `ApplicationContext`. For additional information refer to https://docs.spring.io/spring-framework/docs/current/reference/html/testing.html#testcontext-junit-jupiter-extension[Spring reference].
69
68
<2> `@ContextConfiguration` instructs the spring-test the configuration to use to create the `ApplicationContext`. Since no configuration is specified, the default configuration locations will be tried. This is no different than using the existing Spring Test support. For additional information, refer to the https://docs.spring.io/spring-framework/docs/4.0.x/spring-framework-reference/htmlsingle/#testcontext-ctx-management[Spring Reference]
70
69
71
70
NOTE: Spring Security hooks into Spring Test support using the `WithSecurityContextTestExecutionListener` which will ensure our tests are ran with the correct user.
@@ -225,7 +224,7 @@ For example, the following would run every test with a user with the username "a
0 commit comments