HtmlUnit Integration

Spring 提供了MockMvcHtmlUnit之间的集成。这简化了在使用基于 HTML 的视图时执行端到端测试。此集成允许您:

Spring provides integration between MockMvc and HtmlUnit. This simplifies performing end-to-end testing when using HTML-based views. This integration lets you:

  • Easily test HTML pages by using tools such as HtmlUnit, WebDriver, and Geb without the need to deploy to a Servlet container.

  • Test JavaScript within pages.

  • Optionally, test using mock services to speed up testing.

  • Share logic between in-container end-to-end tests and out-of-container integration tests.

MockMvc 使用不依赖于 Servlet 容器的模板技术(例如,Thymeleaf、FreeMarker 等),但它不适用于 JSP,因为后者依赖于 Servlet 容器。

MockMvc works with templating technologies that do not rely on a Servlet Container (for example, Thymeleaf, FreeMarker, and others), but it does not work with JSPs, since they rely on the Servlet container.