-
Notifications
You must be signed in to change notification settings - Fork 52
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
ParameterizedTests crash on Android 8 with Kotlin code #248
Comments
I have also added this issue on Android's tracker: https://issuetracker.google.com/issues/187242751 |
Thanks for reporting this and sorry for the late response. I've been playing around with this and was able to reproduce it quite easily on an Android 8 emulator. I'm not sure that there's a way to work around this at the moment, as it doesn't seem to be a problem specific to JUnit 5. Translating your block from above to JUnit 4 and Kotlin, I'm able to get the same results and a stack trace very close to the one posted above: import org.jetbrains.annotations.NotNull
import org.junit.Test
class ParameterAnnotationTest {
@Test
fun test() {
javaClass.getDeclaredMethod("testParameterizedWithAnnotation", String::class.java).parameters.forEach {
println("param: $it")
val a = it.getDeclaredAnnotation(NotNull::class.java)
println("annotation $a")
}
}
fun testParameterizedWithAnnotation(value: String) {
}
} Some other observations I made:
The only possible way I could see this being solvable from this end is to restrict or bypass the
Happy to hear your thoughts or new insight since raising the issue. 🙏 |
@paulo-raca Hello again. I'm revisiting this ticket and having a hard time reproducing this with the latest versions of the plugin+instrumentation library enivronment. Just in case you're still invested in JUnit 5 for instrumentation tests, I wanted to reach out and ask if this is something you still encounter on Android 8.x? From my end, it kinda looks like some update along the line has fixed the issue, either through a revision of ART or by means of a change inside JUnit 5 or by accident in something I changed on the instrumentation lib side. Thanks! |
I've run in an annoying crash when using
@ParameterizedTests
on Android 8.0/8.1 devices:After some digging, turns out that inspecting parameter annotations (Which happens in
ParameterizedTestMethodContext.isAggregator(Parameter)
crashes consistently if the method has any annotation present.However I'm using Kotlin to write my tests, and it automatically adds either
@Nullable
or@NotNull
to the parametersIs that a known problem? Any workarounds?
Here is the (Java) code reproducing the issue:
And this is the crash:
The text was updated successfully, but these errors were encountered: