TestNg Supprt
JanCizmar opened this issue · 2 comments
Hello,
as Spring supports TestNG as well, it would be nice to support it as well. Currently @MockBean annotated fields are not initialized.
I am using this workaround, to get it working:
@Configuration
open class MockBeanConfiguration {
@Bean
@Primary
open fun mockS3(): AmazonS3 {
return mockk()
}
}
AFAIK, fields not initialized either if you use Spring Boot's native Mockito support (i.e. MockBean): see spring-projects/spring-boot#7689.
SpringMockK's goal is not to do more than what Spring Boot's Mockito support does. It's only to replicate what it does, using MockK instead of Mockito.
So, if Spring Boot ever supports TestNG and MockBean, and if it needs a change in its Mockito support to do that, then I will apply the same change in SpringMockK. But AFAIK, it's not the case, and will probably never be.
I know it's also a matter of preferences and everything, but IMHO, TestNG was cool when we only had JUnit 3 as an alternative, which didn't support annotations. JUnit 5 is way more advanced than JUnit 3 (or even 4) was, and choosing TestNG over JUnit 5 when testing Spring Boot apps is shooting yourself in the foot, given that Spring and Spring Boot provide native support for JUnit 5 and consider it the de facto testing framework.
I actually never used MockBean with TestNG, so I did't know it's not working. You are probably right. I'll switch back to JUnit. Thanks a lot.