Skip to content

Conversation

@matthewdale
Copy link
Collaborator

Summary

Use the correct mtest.T instance inside subtests to make assertions.

Background & Motivation

Some subtests written using mtest use the testing.T from the outer test function when making assertions. That results in confusing test failures that don't directly indicate which subtest failed. See an example:

=== RUN   TestCSOTProse/8._server_selection/serverSelectionTimeoutMS_honored_for_server_selection_if_it's_lower_than_timeoutMS
=== NAME  TestCSOTProse
    csot_prose_test.go:153: 
        	Error Trace:	/go.mongodb.org/mongo-driver/internal/integration/csot_prose_test.go:153
        	            				/go.mongodb.org/mongo-driver/internal/integration/mongotest.go:232
        	Error:      	Condition never satisfied
        	Test:       	TestCSOTProse
        	Messages:   	expected ping to fail within 150ms

That also corrupts the test failure info in Evergreen CI. The fix is to use the mtest.T instance provided in the subtest func.

@mongodb-drivers-pr-bot mongodb-drivers-pr-bot bot added the review-priority-low Low Priority PR for Review: within 3 business days label Feb 24, 2025
@mongodb-drivers-pr-bot
Copy link
Contributor

API Change Report

No changes found!

@matthewdale matthewdale merged commit ee212da into mongodb:master Feb 27, 2025
29 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-priority-low Low Priority PR for Review: within 3 business days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants