I’m using Riot (https://github.com/thumblemonks/riot) for testing though we could use something else.
I get test output like this:
> ruby my_test_file.rb
Running a test
+ something works
+ something else works
- something failed
I’d like to programmatically access this information. Something like:
test = TestClass.load("my_test_file.rb")
result = test.run
result.errors # some array
Answering my own question. I can post a more detailed answer if anyone’s interested.
The gist of it is evaluating the test files then getting the context from the evaluated test:
Where MyReporter is your implementation that handles pass/fail test results. See https://github.com/thumblemonks/riot/blob/master/lib/riot/reporter.rb