1

I am using Spring Boot 2.5 with Spring Data Elastic Search 4.2.1. I would like to do integration tests. I read https://stackoverflow.com/a/60440334/4068218, but would like to know how I can use those classes, i.e they are not part of Maven imports?

For example, I started with https://github.com/spring-projects/spring-data-elasticsearch/blob/main/src/test/java/org/springframework/data/elasticsearch/junit/jupiter/SpringIntegrationTest.java, but Spring Boot did not recognise @SpringIntegrationTest. I see they are available as part of spring-integration-test, but that is not what I want as I want to use the one under Spring Data Elastic Search.

Sorry could not comment on the other link. I loved the Spring Data Elastic Search documentation - https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#reference, but I don't see anything related to integration tests there.

Any leads are appreciated.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Hari Rao
  • 2,990
  • 3
  • 21
  • 34

1 Answers1

0

Below information might help others -

I am trying testcontainer - https://www.testcontainers.org/modules/elasticsearch/

So far it has been too good.

Hari Rao
  • 2,990
  • 3
  • 21
  • 34
  • How were you able to @Autowire Repository instances into a test? – Josh C. Jun 30 '22 at 16:47
  • @JoshC. If you are using testcontainers for integration test then it gives you an elasticsearch instance under the hood, that spins up before the integration test begins and shuts down when the integration test completes. So not only Repositories, every bean will be instantiated. – Hari Rao Jul 05 '22 at 09:46