0

I have added EmbeddedKafka for testing purpose and introduced 3 more Kafka test cases. Total 8 test cases.

When I am running test cases from intellij all test cases are running as expected (all green) 8/8

While executing maven install or test command Kafka based test cases not considered as consumer stopped so just 5(non-kafka bases) test cases executing.

Code and logs added in below link

https://github.com/kasramp/spring-kafka-test/issues/2

Could you please assist on this ?

StackOverFlow
  • 4,486
  • 12
  • 52
  • 87
  • If you already do those issue on GH, consider then to give us the whole simple project to let us to reproduce an play with. Might something to do with that `@ActiveProfiles("junit-test")`. Why do you use `@ExtendWith(SpringExtension.class)` since `@SpringBootTest` is already one of that? Why do you need `@TestInstance(TestInstance.Lifecycle.PER_CLASS)` ? – Artem Bilan Dec 16 '22 at 15:47
  • @ArtemBilan #1 Extendwith spring extension useful for junit5 class #2 Testinstance - A new test instance will be created once per test class. Full code present here in this repository - https://github.com/kasramp/spring-kafka-test/issues/2 – StackOverFlow Dec 16 '22 at 17:42
  • You didn't get me: `@SpringBootTest` is already marked with that `@ExtendWith(SpringExtension.class)` . I know what `PER_CLASS` does. The question is why do you need it at all? The point is that with Spring it is really not re-created. It is registered as a bean in the application context and of course cached. You didn't answer about `@ActiveProfiles` though and didn't give us a project to play with... – Artem Bilan Dec 16 '22 at 17:50
  • @ArtemBilan We are avoiding unwanted bean creation while running test case. Example- In src code we mentioned if profile!junit-test then Oracle dbconfig created else h2config created. GitHub link mentioned in earlier comment. – StackOverFlow Dec 17 '22 at 04:53
  • What bean do you try avoid? You don't have a `@TestInstance` on your `UserRepositoryTest`, nor `UserKafkaTestcontainersTest`. More over your `UserKafkaProducerTest` has only one `@Test` method. So, all that extra info looks like something not proven to be there.... – Artem Bilan Dec 19 '22 at 15:13
  • I'm not sure why you talk about `8` tests since I see only `4` in the provided project. Doesn't fail for me in IDE and not with Maven. Sorry, but we don't have time to work for your project. Please, provide exact project we can reproduce the problem (if any). – Artem Bilan Dec 19 '22 at 15:21

0 Answers0