Skip to content

testing: allow creation of subtests #9268

Closed

Description

@cflewis

Problem: When writing tests that take >3 minutes each, the tests should be parallelized. If your tests are also amenable to being written in a table-driven format, you have to resort to goroutines to make things parallel (rather than t.Parallel()). If you do that, then your logs get interleaved, and go test run .* can't help you out to isolate particular failures, and you lose the benefits of t.Parallel(), like setting number of parallel lines at CLI, ensuring non-parallel ones don't run with it...

Solution: A proposed solution discussed involves the ability for tests to create their own subtests.

Activity

  1. ianlancetaylor commented on Dec 11, 2014

    @ianlancetaylor
    Contributor

    Marcel said he is working on something along these lines.

  2. neild commented on Dec 11, 2014

    @neild
    Contributor

    It's also easy enough to convert a table-driven test into a set of individual tests, along the lines of:

    type testFoo struct {...}
    func (test testFoo) Test(t *testing.T) { ... }
    func TestFooA(t *testing.T) {
    testFoo{...}.Test(t)
    }

  3. added this to the Unplanned milestone on Apr 10, 2015
  4. changed the title [-]Table-driven testing for parallel integration tests hurts[/-] [+]testing: allow creation of subtests[/+] on Apr 14, 2015
  5. adg commented on Oct 21, 2015

    @adg
    Contributor

    Closing in favor of #12166

  6. locked and limited conversation to collaborators on Oct 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions