Skip to content

testing: the overview documentation on (*T) Run is unclear #35824

Closed as not planned

Description

The package documentation says that

// Run does not return until parallel subtests have completed

But that means that in the example above (see below) the tests aren't run in parallel, because "Run does not return", which I take to mean that the first Run blocks (and then the second too, etc):

//     func TestGroupedParallel(t *testing.T) {
//         for _, tc := range tests {
//             tc := tc // capture range variable
//             t.Run(tc.Name, func(t *testing.T) {
//                 t.Parallel()
//                 ...
//             })
//         }
//     }

Activity

  1. added this to the Backlog milestone on Nov 26, 2019
  2. toothrot commented on Nov 26, 2019

    @toothrot
    Contributor

    @opennota I feel like the documentation for T.Run itself is fairly clear on this behavior:

    https://pkg.go.dev/testing?tab=doc#T.Run

    Run runs f as a subtest of t called name. It runs f in a separate goroutine and blocks until f returns or calls t.Parallel to become a parallel test. Run reports whether f succeeded (or at least did not fail before calling t.Parallel).
    Run may be called simultaneously from multiple goroutines, but all such calls must return before the outer test function for t returns.

    Do you have a suggestion for improving this?

    Also, if you're curious, you can see the go running the tests here: https://github.com/golang/go/blob/go1.13.4/src/testing/testing.go#L960

  3. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Nov 26, 2019
  4. changed the title [-]testing: the documentation on Run is unclear[/-] [+]testing: the overview documentation on (*T) Run is unclear[/+] on Nov 27, 2019
  5. toothrot commented on Nov 27, 2019

    @toothrot
    Contributor
  6. locked and limited conversation to collaborators on Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions