chapter one

1 Spring Boot-specific test tooling

 

This chapter covers

  • What’s included in the "test" Spring Boot Starter
  • How Spring and Boot help you write tests
  • When to use Spring-specific testing tools

Testing applications and verifying that they have the intended behavior is an unavoidable aspect of the development lifecycle. In any serious software engineering project, automating at least some of these tests is table stakes. If you picked up this book, chances are you have already implemented extensive testing yourself, and you do not need to be convinced that you should write tests.

Because it is such a foundational requirement in modern software engineering, many projects in the Spring portfolio cover testing. This includes both Spring Framework and Spring Boot. Spring Framework’s programming model is declarative: you describe your app’s configuration through annotations on classes and methods, such as @Component class MyService. You don’t have to stitch components together imperatively with calls such as new MyService(). Spring brings this paradigm to your test code, with familiar concepts you use in your apps, such as @Autowired, and dedicated test annotations such as @TestConfiguration.

1.1 What’s "Spring Boot Tests"?

1.2 When to use Spring Boot Test

1.3 Why is Spring-specific tooling required?

1.4 Removing the toil: a typical @SpringBootTest

1.5 What you will learn in this book

1.6 Summary