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

Implement expected exception for AnnotationSpec #559

Merged
merged 1 commit into from
Jan 15, 2019

Conversation

LeoColman
Copy link
Member

JUnit's tests can test an exception is thrown by using a parameter in the @Test annotation. https://github.com/junit-team/junit4/wiki/exception-testing

Although we support shouldThrow and it's variants, we're trying to improve the likelihood of people using KotlinTest instead of JUnit, by making the migration as easy as possible. Because of this objective, this commit implements a parameter in @Test, to enable users to configure an expected exception just like JUnit's.

To do this, this commit creates the parameter and annotation processing for it.

To reuse code, this commit moves some internal classes around, to enable kotlintest-core module to use some of the classes from kotlintest-assertions and kotlintest-runner-jvm. This doesn't impact any user, as the moved classes and functions are internal/private.

To test that the new behavior works, this commit uses SpecLevelExtension to map specific tests with specific behaviors. It's not very pretty, but it works.

Fixes #527

JUnit's tests can test an exception is thrown by using a parameter in the `@Test` annotation. https://github.com/junit-team/junit4/wiki/exception-testing

Although we support `shouldThrow` and it's variants, we're trying to improve the likelihood of people using KotlinTest instead of JUnit, by making the migration as easy as possible. Because of this objective, this commit implements a parameter in `@Test`, to enable users to configure an expected exception just like JUnit's.

To do this, this commit creates the parameter and annotation processing for it.

To reuse code, this commit copies some internal classes around, to enable `kotlintest-core` module to use some of the classes from `kotlintest-assertions` and `kotlintest-runner-jvm`. This doesn't impact any user, as the classes were copied. However, they're marked for deletion soon-ish.

To test that the new behavior works, this commit uses `SpecLevelExtension` to map specific tests with specific behaviors. It's not very pretty, but it works.

Fixes #527
@LeoColman LeoColman force-pushed the feature/527-expected-for-annotation-spec branch from 4754dcf to 65e2108 Compare January 14, 2019 17:57
@LeoColman
Copy link
Member Author

If we're ok with this, we should keep this PR opened until we release 3.2.0.

But is everything fine now?

@sksamuel
Copy link
Member

Yep merge after 3.2.0

@sksamuel
Copy link
Member

Approved

@LeoColman LeoColman merged commit 3a80198 into master Jan 15, 2019
@LeoColman LeoColman deleted the feature/527-expected-for-annotation-spec branch January 15, 2019 22:45
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

Successfully merging this pull request may close these issues.

2 participants