How to test query foundry functions?

Hello Team,

I’m trying to test a foundry function which queries from an ontology object, performs multiple aggregations, and returns a 2D aggregations.

I’m using this documentation and works fine on small examples,
https://www.palantir.com/docs/foundry/functions/unit-test-getting-started/

When I try to test query functions, I can only mock so much data. So, is there a better solution?

Thanks!

Hey! The current best practice for using queries in unit tests is stubbing the queries (which I assume you are already using since you linked to the unit test documentation). For complex logic, one common pattern is keeping the actual logic in a function that contains no ontology queries so that function can be tested independently of the queries.

That being said, there is an emulator feature in development that will allow you to mimic a the behavior of queries within a unit test. This emulator will use the data created in your unit test and most queries will just work like you would expect (there will be some functionality that will still require stubbing such as fuzzy searches). This feature should be later this year or early next year.