We have an object (let's call it Child) with a formula field that does a lot of checking of various fields and spits out a numeric result (estimated number of days some work will take, based on a bunch of flags and conditions).
Another object (Parent) has multiple Children related to it through a lookup.
I wrote an apex class that aggregates the Children of a Parent in various ways based on several fields, including the formula result. I now want to test that logic, but when I try to create some sample Children to feed into my test, I'm told that I can't write to formula fields.
I don't want to figure out how to build a tree of objects and set specific fields to get the value I want to test from the formula field. Furthermore, the formula has a limited set of results, which may change in the future (say, the business decides that some particular type of work takes 8 days instead of 10). I want to test various edge cases that the formula can't produce today.
What's the best approach to this?