https://github.com/daggerok/spring-boot-junit-jupiter-minimal-setup
Spring Boot 2.x and Junit 5 minimum required pom.xml configuration
https://github.com/daggerok/spring-boot-junit-jupiter-minimal-setup
junit junit-jupiter junit5 minimal spring-boot spring-boot-2 spring-boot-test
Last synced: 11 months ago
JSON representation
Spring Boot 2.x and Junit 5 minimum required pom.xml configuration
- Host: GitHub
- URL: https://github.com/daggerok/spring-boot-junit-jupiter-minimal-setup
- Owner: daggerok
- Created: 2019-03-16T16:22:54.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-16T16:39:28.000Z (almost 7 years ago)
- Last Synced: 2025-01-10T00:41:53.215Z (about 1 year ago)
- Topics: junit, junit-jupiter, junit5, minimal, spring-boot, spring-boot-2, spring-boot-test
- Language: Java
- Size: 56.6 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# spring-boot junit5 minimal setup
Spring Boot 2.x and Junit 5 minimum required pom.xml configuration
_pom.xml_
```xml
org.springframework.boot
spring-boot-starter-parent
2.1.3.RELEASE
5.4.0
org.junit.jupiter
junit-jupiter-api
test
org.junit.jupiter
junit-jupiter-engine
test
org.springframework.boot
spring-boot-starter-test
test
```
_MyTest.java_
```java
@TestConfiguration
@SpringBootApplication
class ApplicationUnderTest {
@Bean
String aString() {
return "Hello!";
}
public static void main(String[] args) { // <-- main method is optional...
SpringApplication.run(ApplicationUnderTest.class, args);
}
}
@SpringBootTest
@ExtendWith(SpringExtension.class)
class MyTest {
@Autowired
String aString;
@Test
void test() {
assertThat(aString).isEqualTo("Hello!");
}
}
```