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

Introduce Test Types #4935

Open
Tracked by #5066
Samyoul opened this issue Mar 15, 2024 · 1 comment
Open
Tracked by #5066

Introduce Test Types #4935

Samyoul opened this issue Mar 15, 2024 · 1 comment
Labels

Comments

@Samyoul
Copy link
Member

Samyoul commented Mar 15, 2024

Problem:

  • As a developer, I want to run automated validation tests on any new or amended integrations test, so that I can be confident that the test is no flaky.
    • See the Tests Policy.
  • As a developer, I need a way discriminate between integration tests and non-integration tests, so that I can I don't run automated tests unnecessarily.

Proposal:

Labels

Create a set of test labels. eg:

  • e2e
  • integration
  • unit
  • network

Usage

Prepend the test function name with the tag(s), and execute tests with -run <LABEL>

See examples below:

Command:

go test -run Integration
go test -run Unit

Identify test as integration, will run with integration tests and all tests.

func TestIntegrationMessengerSomeThing(t *testing.T) {
    // The body of the test
}

Identify test as integration, will ONLY run with integration test commands

func TestIntegrationMessengerIntOnly(t *testing.T) {

    if m := flag.Lookup("test.run").Value.String(); m == "" || !regexp.MustCompile(m).MatchString(t.Name()) {
        t.Skip("skipping as execution was not requested explicitly using go test -run")
    }
    // The body of the test
}

Identify test as unit and network, will run with unit or network, and all tests.

func TestUnitNetworkMessengerSomeOtherThing(t *testing.T) {
    // The body of the test
}

Reference

Docs : https://pkg.go.dev/testing#hdr-Subtests_and_Sub_benchmarks
Following from : #4908 (comment)

@Samyoul
Copy link
Member Author

Samyoul commented Mar 15, 2024

We could have a messenger tag that treats Messenger tests as their own type to split Messenger. Or messenger && integration labels, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant