Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Improve Test Failure Descriptions #118

Open
foxytanuki opened this issue Dec 23, 2023 · 0 comments
Open

Improve Test Failure Descriptions #118

foxytanuki opened this issue Dec 23, 2023 · 0 comments

Comments

@foxytanuki
Copy link
Member

Context

In our unit tests, we use a structure that includes a slice of structs for defining test cases:

testCases := []struct {
    creator                  string
    name                     string
    parent                   string
    registrationPeriodInYear uint64
    domainOwnership          types.DomainOwnership
    expErr                   error
    fn                       func()
}{

Source

The test functions execute these cases in a specified order:

suite.Run(fmt.Sprintf("Case %d", i), func() {

Source

Issue

The challenge arises when tests fail. The output is not specific about which test types are failing, making it difficult to pinpoint the issue. For example:

--- FAIL: TestKeeperTestSuite/TestRegisterSecondLevelDomain/Case_2 (0.01s)
--- PASS: TestKeeperTestSuite/TestRegisterSecondLevelDomain/Case_3 (0.01s)
--- FAIL: TestKeeperTestSuite/TestRegisterSecondLevelDomain (0.09s)
--- FAIL: TestKeeperTestSuite (0.09s)

Suggested Action

I propose enhancing the test structure by adding descriptive labels or comments to each test case within the struct slice. This adjustment will make the test failure outputs more informative, aiding in quicker identification and resolution of issues.

testCases := []struct {

    creator                  string
    name                     string
    parent                   string
    registrationPeriodInYear uint64
    domainOwnership          types.DomainOwnership
    expErr                   error
    fn                       func()
    desc                     string
}{
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant