File tree Expand file tree Collapse file tree
src/test/java/com/baeldung/junit5/spring Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929 <maven-compiler-plugin .version>3.6.0</maven-compiler-plugin .version>
3030 <maven-surefire-plugin .version>2.19.1</maven-surefire-plugin .version>
3131 <junit4 .version>4.12</junit4 .version>
32+ <spring .version>5.0.1.RELEASE</spring .version>
3233 </properties >
3334
3435 <build >
111112 <version >${junit4.version} </version >
112113 <scope >test</scope >
113114 </dependency >
115+ <dependency >
116+ <groupId >org.springframework</groupId >
117+ <artifactId >spring-test</artifactId >
118+ <version >${spring.version} </version >
119+ <scope >test</scope >
120+ </dependency >
121+ <dependency >
122+ <groupId >org.springframework</groupId >
123+ <artifactId >spring-context</artifactId >
124+ <version >${spring.version} </version >
125+ </dependency >
114126
115127 </dependencies >
116128
Original file line number Diff line number Diff line change 1+ package com .baeldung .junit5 .spring ;
2+
3+ import static org .junit .jupiter .api .Assertions .assertTrue ;
4+
5+ import org .junit .jupiter .api .Test ;
6+ import org .junit .jupiter .api .extension .ExtendWith ;
7+ import org .springframework .test .context .ContextConfiguration ;
8+ import org .springframework .test .context .junit .jupiter .SpringExtension ;
9+
10+ import com .baeldung .junit5 .Greetings ;
11+
12+ @ ExtendWith (SpringExtension .class )
13+ @ ContextConfiguration (classes = { SpringTestConfiguration .class })
14+ public class GreetingsSpringTest {
15+
16+ @ Test
17+ void whenCallingSayHello_thenReturnHello () {
18+ assertTrue ("Hello" .equals (Greetings .sayHello ()));
19+ }
20+
21+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .junit5 .spring ;
2+
3+ import org .springframework .context .annotation .Configuration ;
4+
5+ @ Configuration
6+ public class SpringTestConfiguration {
7+
8+ }
You can’t perform that action at this time.
0 commit comments