4 ms·
Findall is just a cartesian product...something easily available in pretty much any language out there. Not that I think Prolog is a bad fit for test data gener
by saosebastiao 12y ago
Findall is just a cartesian product...something easily available in pretty much any language out there. Not that I think Prolog is a bad fit for test data generation, just that this example is entirely too simple to show its power.
Where Prolog becomes really powerful for this use case is modeling the underlying business rules and selectively creating test cases that acknowledge those rules. A tiny bit of familiarity with Prolog goes a long way here. I've modeled about 95% of the underlying logic of 50k SLOC Java business rule systems using less than a hundred lines of Prolog. And the ability to infer both forward and backwards is extremely powerful (ex. if you have created F(X,Y) = Z, then you implicitly have a rule for determining X given Y and Z).
- gowan 12y agoauthor here: Yes, this example is simple. IMO it's best to introduce people to what they are familiar with. I didn't want to write an example that demonstrated the full power of prolog but lost 90% of the crowd. My hope was that this would spark curiosity in how prolog can be used to generate test cases. At the moment I'm using the technique in the post to generate happy path test cases for an application with lots of buisness rules.