-1

I have defined several spring beans via @Bean.

@Bean
void SomeClass someClass() {
return new SomeClass();
}

But these are not covered by unit tests as I use @Mock to mock the classes, and beans are not instantiated in unit tests.

Now test coverage is failing because spring bean definition lines are not covered, is there any way to fix it ?

We use Jacoco coverage.

Note: I am not using @Configuration, rather passing the class to Application context

1 Answers1

0

@Configuration files are normally excluded from code-coverage tests by rule. Running the application with @SpringBootTest (if you're using Boot) may also cause these to be marked as executed.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152