-
Notifications
You must be signed in to change notification settings - Fork 641
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
ExpectedException for AnnotationSpec #527
Labels
enhancement ✨
Suggestions for adding new features or improving existing ones.
Milestone
Comments
LeoColman
added
the
enhancement ✨
Suggestions for adding new features or improving existing ones.
label
Jan 7, 2019
Yes I suppose for AnnotationSpec we should.
…On Mon, 7 Jan 2019, 11:37 Kerooker ***@***.*** wrote:
In the same line of #522
<#522>, JUnit has an
Annotation called Expected.
This annotation verifies that the test threw an Exception or a subclass of
it.
For example:
@expected(FooException::class)
@test
fun foo() {
throw FooException() // Test passes
}
@expected(BarException::class)
@test
fun bar() {
println("Bar?") // Test fails, BarException wasn't thrown
}
Should we also support it?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#527>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAtZGpuGt1-iRZAuXLu9yybY6xN5EdPCks5vAzGBgaJpZM4ZzWLJ>
.
|
LeoColman
added a commit
that referenced
this issue
Jan 14, 2019
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
LeoColman
changed the title
@Expected for AnnotationSpec
ExpectedException for AnnotationSpec
Jan 14, 2019
LeoColman
added a commit
that referenced
this issue
Jan 14, 2019
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
added a commit
that referenced
this issue
Jan 15, 2019
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the same line of #522, JUnit has a parameter in
@Test
calledexpected
This parameter verifies that the test threw an Exception or a subclass of it.
For example:
Should we also support it?
The text was updated successfully, but these errors were encountered: