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

Create tool to help writing tabular input test cases. #1921

Closed
fressi-elastic opened this issue Mar 3, 2025 · 0 comments
Closed

Create tool to help writing tabular input test cases. #1921

fressi-elastic opened this issue Mar 3, 2025 · 0 comments

Comments

@fressi-elastic
Copy link
Contributor

It would be nice to have a decorator to facilitate creating table-driven unit tests (https://go.dev/wiki/TableDrivenTests).

Example of use:

@dataclass
class SumCase:
    values: list[int]
    want: int


@cases(
    no_values=SumCase(values=[], want=0),
    two_values=SumCase(values=[1, 2], want=3),
)
def test_sum(case: SumCase):
    assert sum(case.values) == case.want
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant