I am using tests with Cucumber and Spring Boot
@CucumberContextConfiguration
@ActiveProfiles(profiles = { "cucumber" })
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@ExtendWith(SpringExtension.class)
public class FooTest {
@Autowired
BatchService batchService;
@MockBean
S3ClientService s3ClientService;
@MockBean
HttpClientService httpClientService;
@SpyBean
UndueService undueService;
@Given("^foo cucumber test$")
public void foo_cucumber_test() {
System.out.println("Foo Test");
}
}
When I run/debug my test with a break point on @Given method
I got this weird behavior, the @Mockbean
/@SpyBean
are correctly injected but in the test class its values are null
!! and I can't run Mockito functions verify
or when
But when I run a test without cucumber
@Test
void fooTest() {
System.out.println("Foo Test");
}
It works fine !! the values are not null