Skip to content

Could you explain on why t.Cleanup is required over defer in some situations? #23

@brandur

Description

@brandur

tparallel will require the use of t.Cleanup instead of defer in cases where a top-level test case has subtests, and that top-level test case is t.Parallel. From the README:

Although t.Parallel() is called in the sub-test function, it is post-processed by defer instead of t.Cleanup()

I was bringing t.Parallel into a project and had to make some changes related to this, but was having a hard time explaining to my colleague why exactly those changes are necessary.

Could you elaborate a little more on why exactly t.Cleanup needs to be used instead of defer in some cases? I can help expand the README to explain it if you'd like (after I understand it myself that is).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions