mercredi 12 août 2020

Maven tests can't resolve autowired spring boot dependencies

Spring Boot tests, when executed through Intellij are running fine. But when I run tests with Maven, they fail.

I use this Maven test command:

mvn test

Reasons found in the surefire plugin report:

------------------------------------------------------------------------- Test set: com.miro.project.controllers.ProjectTest ------------------------------------------------------------------------------- Tests run: 5, Failures: 0, Errors: 5, Skipped: 0, Time elapsed: 7.839 s <<< FAILURE! - in com.miro.project.controllers.ProjectTest signupSuccess Time elapsed: 0 s <<< ERROR! java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'acmeApplication': Unsatisfied dependency expressed through constructor parameter 0;

And in terminal (after tests are executed):

IllegalState Failed to load ApplicationContext

In my tests, all dependencies are loaded with @Autowired annotation. I am using Java8, Maven 3.6.3 and Spring Boot 2.3.0

Any idea?

Thank you.

Aucun commentaire:

Enregistrer un commentaire