samedi 11 juillet 2020

How do I test a function which returns a complex object?

I'm trying to test a function in java, which helps me create a bool query in elasticsearch and returns a QueryBuilder object.

public QueryBuilder getBoolQueryForRequest(request) {

    // .. bool query creation logic

    return boolQuery;
}

The logic for query creation is complex and thus the object which can be asserted against the return value of this function is involved. How should I go about my testing?

This link talks about converting the QueryBuilder to a string query and then comparing, but again, the only way to test the original code is to use the original code to create the object, which is kind of a catch-22 for me..

Aucun commentaire:

Enregistrer un commentaire