Introduction to Cypress

Learn to use Cypress for testing to overcome the limitations of @WebMvcTest.

Earlier, we used @WebMvcTest to start a mock servlet environment for our testing. It had a few limitations which we’ll discuss below.

Drawbacks of @WebMvcTest

While @WebMvcTest has a lot of advantages, there are also a few drawbacks:

  • There might be a difference between the mock servlet environment and the actual behavior of Tomcat.

  • We are not doing an end-to-end test from HTML to the database. That interaction might have some hidden bugs that we might not find by using Mockito mock services.

  • Writing HtmlUnit tests is not very visual. We need to start the actual application to reference the result of the Thymeleaf template.

  • HtmlUnit is not using an actual browser, so the execution of JavaScript and CSS might be different.

Get hands-on with 1400+ tech skills courses.