SG Tech Edge
SG Tech Edge

Reputation: 507

Can I check with mockmvc if an endpoint exist?

I am trying to check if a particular endpoint of a controller exists. By now I am not interested checking the response or status codes. Is there a way to just check the existence?

Upvotes: 1

Views: 960

Answers (1)

Christopher Schneider
Christopher Schneider

Reputation: 3915

This is not possible. It's emulating a web request, so unless you return that information in a standard request, you cannot check that an endpoint exists. The best you can do is check for a 404 status, but that doesn't necessarily mean that an endpoint doesn't exist.

You may be able validate an endpoint's existence another way, by looking at what endpoints Spring has mapped with RequestMappingHandlerMapping

See this answer.

Upvotes: 1

Related Questions