Skip to content
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

suite: Multiple test runs #1245

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

eisandbar
Copy link

Summary

Added ability to run tests multiple times with a single SetupSuite and TearDownSuite

Changes

Running go test now accepts flag testify.c which defines how many times we want each test to run
Modified tests that expect the test to run only once

Motivation

Previously the method to run multiple tests was using flag -test.count or -count.
The problem with that is that SetupSuite is called multiple times, and if it takes a long time to complete then the tests will also take a long time. Since these tests are all in the same test suite, they should be able to reuse the same SetupSuite.

As an example, running go test -count=10 completes in about 15.5s and running go test -testify.c=10 completes in about 8.9s, halving the time to complete.

Related issues

#1154

Suite now accepts flag testify.c of type uint that defines how many times each test will run. Test creation has been refactored into a separate function for readability purposes. In Run each test is now appended to tests testCount times.
Fixed tests where the hardcoded expected value should scale with the amount of times the test is run.
@dolmen dolmen added enhancement pkg-suite Change related to package testify/suite labels Oct 30, 2023
@dolmen dolmen changed the title Multiple test runs suite: Multiple test runs Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement pkg-suite Change related to package testify/suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants