grpctest: Parent testing.T used for logging when running subtests with t.Run #7968
Labels
Area: Testing
Includes tests and testing utilities that we have for unit and e2e tests within our repo.
Type: Testing
What version of gRPC are you using?
1.69
What version of Go are you using (
go version
)?N/A
What operating system (Linux, Windows, …) and version?
N/A
What did you do?
Run a test that follows table driven style, similar to
TestUnmarshalListener_WithUpdateValidatorFunc
which has multiple subtests run usingt.Run()
.grpc-go/test/xds/xds_security_config_nack_test.go
Line 43 in 724f450
What did you expect to see?
In the test logs, ordering of events should be as follows:
Example:
What did you see instead?
The parent test name is interleaved in subtest logs.
Root Cause
This issue is seen because the parent function's
*testing.T
is used to log for all substestsgrpc-go/internal/grpctest/grpctest.go
Lines 104 to 125 in 724f450
grpc-go/internal/grpctest/grpctest.go
Lines 53 to 61 in 724f450
A manual fix would be to call
grpctest.Tester.Setup(t)
at the beginning of each subtest. I tried finding a way of giving a setup hook totesting.T
(similar to the t.Cleanup functions that run after tests), but there isn't a public API to do this. Sincetesting.T
is a struct and not an interface, wrapping it to intercept call tot.Run
isn't an option too.The text was updated successfully, but these errors were encountered: