Spring Boot Testing Concepts: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
=External= | |||
* https://www.baeldung.com/spring-boot-testing | |||
=Internal= | =Internal= | ||
* [[Spring_Boot_Concepts#Testing|Spring Boot Concepts]] | * [[Spring_Boot_Concepts#Testing|Spring Boot Concepts]] | ||
* [[Spring_Framework_Testing_Concepts#Spring_Boot_Testing_Concepts|Spring Framework Testing Concepts]] | * [[Spring_Framework_Testing_Concepts#Spring_Boot_Testing_Concepts|Spring Framework Testing Concepts]] |
Revision as of 01:04, 3 October 2021
External
Internal
Overview
Process: https://spring.io/blog/2016/04/15/testing-improvements-in-spring-boot-1-4
Dependencies
Use:
dependencies {
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
This started dependency pulls everything that is needed to write JUnit tests.
Annotations
@SpringBootTest - this is required, otherwise beans won't get injected in our tests.
@RunWith(SpringRunner.class)
@IntegrationTest, @WebIntegrationTest
SpringBoot Test Example
@RunWith(SpringRunner.class)
@SpringBootTest
public class MyTests {
@Autowired
private SomeComponent someComponentWeWantToTest;
// ...
}
Testing Logging Configuration
By default, test logging is executed by Logback.