Tips, tricks and gotchas when writing unit tests with Mockito by Jesse Kershaw

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.พ. 2024
  • Mockito is synonymous with Unit Testing in Java and yet people often misuse features and write tests that are brittle and difficult to maintain. This talk aims to go over the common features of the mockito mocking library, common anti-patterns and better alternatives so that your tests are more understandable and easier to maintain. From how to create mocks and mock behaviour to how to inject mock beans in to a spring boot integration test context.
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 7

  • @KessirAdjaho
    @KessirAdjaho 5 หลายเดือนก่อน +6

    It's always important to mention the potential downsides of @MockBean. Its abuse can considerably slow down your integration tests and increase memory usage. Anytime you use @MockBean, you may be creating an additional spring context, which are expensive.

    • @JavaWedsPython
      @JavaWedsPython 4 หลายเดือนก่อน

      Thanks for sharing!

    • @aelfric5578
      @aelfric5578 หลายเดือนก่อน

      Do you mean when you use @MockBean together with the full @SpringBootTest or can this cause issues even when using a smaller context (e.g. specifying the classes argument on the SpringBootTest annotation like in the sides)?

  • @jesper7605
    @jesper7605 5 หลายเดือนก่อน +2

    Easy to understand and covered several useful concepts. Good job!

  • @metaltoad8462
    @metaltoad8462 5 หลายเดือนก่อน +1

    finally, someone said read the manual or official documentation

  • @ShivamNagpal
    @ShivamNagpal 5 หลายเดือนก่อน

    Awesome Talk!!

  • @jackofnotrades15
    @jackofnotrades15 5 หลายเดือนก่อน

    Great talk