Skip to content

Feature request: add a tag for the unit test coverage approach #65

@simon-something

Description

@simon-something

It would be interesting to find a way to specify the coverage used while building a tree (and reflect it in the test contract name or top-level comment).

For instance, for the following function and coverage type, we'd scaffold 2 tests contracts which we could name Foo_Test_Branch and Foo_Test_FullPath

bool foo (bool x, bool y) {
    if (a && b) {
        return true;
    }
    return false;
}

based on the following coverages (amongst other possibilities):

  • branch coverage: where we're assessing if we covered every result of every decision structure (tested both true and false in an if for instance)
flowchart TD
    A[foo] --> C{a && b}
    C -->|True| D[return true]
    C -->|False| E[return false]
Loading

with the tree

TestMe::foo(branch)
├── when a and b are true
│   └── it should return true
└── when a is false
    └── it should return false
  • path coverage: where we're assessing if we are covering each flow within the function under test
flowchart TD
    A[foo] --> C{a}
    C -->|True| D{b}
    C -->|False| E{b}
    D -->|True| F(true)
    D -->|False| G(false)
    E -->|False| H(false)
    E -->|False| I(false)
Loading

with the following tree

TestMe::foo(full path)
├── given a is true
│   ├── when b is true
│   │   └── it should return true
│   └── when b is false
│       └── it should return false
└── given a is false
    ├── when b is true
    │   └── it should return false
    └── when b is false
        └── it should return false

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatNew feature or requestUphillNeeds research before being implemented

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions