oracle-samples/clara-rules

Improve testing for the explain-activations function in session inspection

Opened this issue · 0 comments

#346 reported a bug that caused the explain-activations function to throw an exception. We previously didn't have any testing of this function; we just tested the underlying session inspection functionality that it used. As part of that PR, a simple test validating that explain-activations could run without throwing an exception was added. Ideally we'd have some more testing of explain-activations though, with the caveat that we wouldn't want to simply retest session inspection. Explain-activations doesn't need to be concerned with edge cases of how sessions are inspected that the tests of inspection need to deal with since it is just a layer on top of whatever data is returned by inspection.

My initial thoughts here would be to validate that the string representations of the relevant facts are contained within the output of explain-activations, possibly bookended by particular keywords. I'm concerned that testing for the exact string output would be too brittle. Currently explain-activations uses println, so in order to test the string output we can either use with-out-str or refactor it to have a helper function, say explain-activations*, generate a string printed out by explain-activations, then test the output of explain-activations*.