Best practices for automated tests

In our (Java) unit tests we would like to test the integration of Elasticsearch (e.g. do queries work, can docs be indexed correctly, etc.). I'm wondering if there are any best practices or recommendations regarding this topic?

Here are some additional thoughts/questions from my side:

  • My preferred solution would be to run the test against a real, "always-running" Elasticsearch instance. However in our current company/environment this is not possible.
  • For certain ORMs (e.g. Entity Framework in the dotnet world) there exist in-memory representations that are meant to be used for tests. Is there something similar in the elastic world?
  • I found the ESSingleNodeTestCase-class. However I didn't find much documentation nor any examples, etc. Plus I read that it can be quite tedious to set up. Is This still supported and recommended?
  • The requirement is that these tests can be executed locally (e.g. in IntelliJ) as well as on our build server.

Thanks in advance for any answers. :slight_smile:

To do integration tests, you can:

For sure, integration tests must be run against a real elasticsearch instance.
Unit tests should not require any third party tool to run IMHO.

Thanks a lot for your quick reply. I agree that unit tests should not access or require any third party tool. On the other hand I think it's helpful to unit test in a "as real as possible"-situation. That's why some kind of in-memory or something like that would be cool.

Would that maybe be possible with the ESSingleNodeTestCase?

As far as I can see, all the mentioned solutions require Docker or download some other stuff.

Thank you very much. :slight_smile:

FYI - I just posted a follow up question here:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.