Skip to content

Fix use of testing.T instead of mtest.T in assertions in subtests. #1963

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

Merged
merged 1 commit into from
Feb 27, 2025

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 priority-3-low Low Priority PR for Review label Feb 24, 2025
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
priority-3-low Low Priority PR for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants