ArgumentCaptor in practice

Pac-Man as ArgumentCaptor

1. Definition

Use it to capture argument values for further assertions.

2. Example

In order to illustrate, I created a model based on Ticket (I don’t have experience on that), and the target is to show the ArgumentCaptor on PaymentService class.

Ticket class diagram
TicketService class
TicketServiceTest class

3. Conclusion

Using ArgumentCaptor, is easy, fast and safe to change the code, add new code and complete your task 📕.

4. Tech stack

  • Java 11
  • JUnit 5
  • Lombok
  • AssertJ
  • Mockito

5. References

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Luiz Gustavo De O. Costa

Luiz Gustavo De O. Costa

Hey friend!! I’m Luiz Gustavo, a Java developer and I’m here to learn and write about Java, tests and good practices