-
Notifications
You must be signed in to change notification settings - Fork 53
Instrumentation tests do not run with service registered junit5 extensions #229
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
Comments
I might just need to set junit.jupiter.extensions.autodetection.enabled, I'll reopen if something more is required. |
I tried without luck
|
Thanks for bringing this up. The bridge API for running JUnit 5 tests using a JUnit 4-compatible |
Feel free to close if you don't intend to support. It's frustrating but there is a verbose workaround. |
I'll leave it open for now and will check in with the JUnit Team to sync on the intended support for extensions using the old Runner. Will update here as new info comes in! |
Looking into this again. Since the JUnit 5 Either way, I'm targeting this for the next release. |
Is there a change I should make to the discovery request I'm building here? https://github.com/square/okhttp/blob/master/native-image-tests/src/main/kotlin/okhttp3/RunTests.kt#L109-L116 Before or after your next release? Thanks for your help on this. |
The change would only affect the on-device tests running with the JUnit4/5 hybrid. Not sure about the environment that your Starting from the next version, you'll be able to apply configuration parameters (including the one for auto-detection of extensions) to the instrumentation test runtime through the existing DSL in the build script. This will allow android {
defaultConfig {
// This will become possible in 1.7.0.0.
// The value is a comma-separated list, if you need to set more than one
testInstrumentationRunnerArgument("configurationParameters", "junit.jupiter.extensions.autodetection.enabled=true")
}
} The video below exercises a simple instrumentation test with an class ExampleExtension : ParameterResolver {
override fun supportsParameter(parameterContext: ParameterContext, extensionContext: ExtensionContext): Boolean =
parameterContext.parameter.type == Int::class.java
override fun resolveParameter(parameterContext: ParameterContext, extensionContext: ExtensionContext): Any =
1000
}
class ExampleExtensionTest {
@Test
fun test(value: Int) {
assertEquals(1000, value)
}
} The test passes once the extension is auto-detected at runtime. I will provide a |
This is now released in |
See this PR
When running existing working JVM tests on Android also. I need to add a compile time dependency on the library providing and registering the extension
https://github.com/square/okhttp/pull/6420/files#diff-4e370c937fb7a9a796291fe5a460c222a5fa57f5e400aa48c5eef8a7d22d7ec7
Then explicitly refer to it
https://github.com/square/okhttp/pull/6420/files#diff-83a70a0ad7b461e83feaa5a3e9412f76257a3fdde5a6a2f603ab142a13da806a
The text was updated successfully, but these errors were encountered: