Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

erunion's avatar

Unit testing Elasticsearch queries

Right now all of our unit tests talk to MySQL and Elasticsearch. I'm working on moving the tests over to using a mix of DB mocks and SQLIte, but I'm curious how you all work with unit testing Elasticsearch.

I know I could just overload the Elastic handlers in our app with mocks, but that wouldn't really test anything, because who knows if the queries in the code actually work or not.

0 likes
2 replies
olimorris's avatar

Why wouldn't you want to use some sort of integration testing to test the results from the queries?

1 like
erunion's avatar

We want to do that, yeah, but the problem is (right now) our test suite is a mix of integration and unit tests and all total takes 5 minutes to complete. It's pretty brutal to have to wait 5 minutes to wait for them to finish.

Please or to participate in this conversation.