thombergs / code-examples

A collection of code examples from blog posts etc.
MIT License
2.65k stars 2.64k forks source link

Spring Boot Validation #95

Open Nandakumar-M opened 3 years ago

Nandakumar-M commented 3 years ago

Hi,

This is regarding the blog post on spring boot validation.

Under Validating Input to a Spring Service Method, the test for verifying this validation uses @ExtendWith(SpringExtension.class) and @SpringBootTest.

I am trying to keep service layer unit tests free of Spring framework (as recommended here). Unfortunately, unit tests written this way do not trigger validation.

Would be great if you can throw some light on how validation in service layer can be unit tested without using @SpringBootTest. Thanks.

Regards, Nanda

Nandakumar-M commented 3 years ago

Will try Validating Programmatically and get back on this.