From the course: Advanced Spring: Effective Integration Testing with Spring Boot

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating human-readable tests with Mockito and AssertJ

Creating human-readable tests with Mockito and AssertJ

From the course: Advanced Spring: Effective Integration Testing with Spring Boot

Start my 1-month free trial

Creating human-readable tests with Mockito and AssertJ

- [Instructor] The code and tests tends to be disorganized. Some mocks here and there, interleaved with assertions and test method calls. Let's look at the given-when-then methodology with BDDMockito and AssertJ to create human readable tests. Given-when-then methodology arrived from a very popular AGL development process called BDD or behavior-driven development. BDD, which emerged from TDD, brings to the table a human friendly style of writing test scenarios by structuring the test into three parts. Given is where we put our preconditions and requirements for this use case. When is the action that we want to test. Usually this involves calling no more than one or two lines of code. Then is used to verify what should happen after the execution of the action. It is represented usually by assertions to more classes and validation of returned results. This brings more clarity in our tests as we are following a natural language that is easy to read not only by developers but also by…

Contents