Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 8, 2023
Merged

Conversation

jaypipes
Copy link
Member

@jaypipes jaypipes commented Aug 8, 2023

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

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

Signed-off-by: Jay Pipes <jaypipes@gmail.com>
@jaypipes jaypipes merged commit 0d8a00e into main Aug 8, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant