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

@TestCase decorator #25

Closed
Aboisier opened this issue Feb 8, 2019 · 3 comments
Closed

@TestCase decorator #25

Aboisier opened this issue Feb 8, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@Aboisier
Copy link
Collaborator

Aboisier commented Feb 8, 2019

The current test case syntax is pretty ugly in my opinion.

@Test('My test', [
      new TestCase('Two plus two is four', 2, 2, 4),
      new TestCase(`Minus one that's three`, 4, -1, 3)
])
quickMaths(a: number, b: number, result: number) {
    expect.toBeEqual(a + b, result);
}

I think we can improve this. Here are a few examples of how we could go about it:

I like this syntax, but I'm not sure where we would put the timeout parameter, and we lose the opportunity to have a custom root-test name.

@TestCase('Two plus two is four', 2, 2, 4)
@TestCase(`Minus one that's three`, 4, -1, 3)
quickMaths(a: number, b: number, result: number) {
    expect.toBeEqual(a + b, result);
}

This option solves the name and timeout parameters problem and is still more readable than the current implementation.

@Test()
@TestCase('Two plus two is four', 2, 2, 4)
@TestCase(`Minus one that's three`, 4, -1, 3)
quickMaths(a: number, b: number, result: number) {
    expect.toBeEqual(a + b, result);
}
@Aboisier Aboisier added the enhancement New feature or request label Feb 8, 2019
@bryanmenard
Copy link

I like the proposed syntax. However, I think having a separate decorator for the timeout (@Timeout) would be a good solution, too.

I think it's cleaner for regular tests (avoids having to pass empty arguments when we need a timeout but no test name) and also solves this issue.

@Aboisier
Copy link
Collaborator Author

Aboisier commented Feb 8, 2019

I really like this solution! I was definitely pretty annoyed by the empty argument.

@Aboisier Aboisier changed the title TestCase decorator @TestCase decorator Feb 8, 2019
@Aboisier
Copy link
Collaborator Author

Implemented in #29 .

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

No branches or pull requests

2 participants