gdt-dev / gdt

Go Declarative Testing
Apache License 2.0
4 stars 2 forks source link

call t.Error() from sub-tests not Scenario.Run() #10

Closed jaypipes closed 1 year ago

jaypipes commented 1 year ago

This patch addresses a couple related problems, all with the evaluation of testing.T failures. When testing.T.Run() is executed, a new goroutine is spawned with a new testing.T pointer. This specific goroutine's testing.T pointer needs to have its testing.T.Error() method called in order for that sub-test to be marked failed. We were erroneously calling testing.T.Error() within the Scenario.Run() method instead of inside the Spec.Eval() method, which resulted in the test scenario being marked failed instead of the individual test unit.

We address the exec plugin's Spec.Eval() in this patch to call testing.T.Error() on any assertion failure however additional patches are coming for the http and kube plugins.

Finally, I made a change to the gdterrors.TimeoutExceeded() function to allow for an assertion failure message to be supplied to the error producer, making it easier for folks to see "this test assertion failed to succeed before a timeout of (duration)".

Addresses Issue #8