Using Appropriate Annotations in Spring Testing

1. Introduction

There's heavy use of annotations in Spring Framework. This makes confusion about what annotations should be used especially in tests. It sometimes ends up with adding redundant annotations or the tests not working as expected. On StackOverflow, you can easily find the developers who make mistakes with Spring annotations or someone who makes things work but does not fully understand why.

To make things clear, in this article, I would summarize the annotations we should use in each testing scenario using JUnit 5 and Spring Test Framework.