0

I know that when using webEnvironment=RANDOM_PORT in a spring test, spring will run a web server and the test will cover scenarios starting from real http request while webEnvironment=MOCK will only mock a web server's behavior.

I've already looked at Difference between webEnvironment = RANDOM_PORT and webEnvironment = MOCK.

As it is not answered in the similar question, it is still unclear which failure scenarios will be caught when RANDOM_PORT is used that MOCK is incapable of catching it.

Thanks is advance.

Morteza
  • 642
  • 7
  • 17

1 Answers1

0

I found an example in the docs

For example, Spring Boot’s error handling is based on the “error page” support provided by the Servlet container. This means that, whilst you can test your MVC layer throws and handles exceptions as expected, you cannot directly test that a specific custom error page is rendered. If you need to test these lower-level concerns, you can start a fully running server as described in the next section.

Morteza
  • 642
  • 7
  • 17