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
Fix lifecycle for Junit 5 extension. #7392
Conversation
# Conflicts: # okhttp-coroutines/src/jvmTest/kotlin/okhttp3/SuspendCallTest.kt
@swankjesse requesting post review. Reviews from anyone else very welcome, especially on Junit5 usage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t like how we have to do an annotation and book-keeping to support multiple MockWebServer instances, especially since almost nobody is going to need it.
import org.junit.jupiter.api.extension.RegisterExtension | ||
|
||
@ExtendWith(MockWebServerExtension::class) | ||
class ExtensionLifecycleTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great
assertThat(server.started).isTrue() | ||
} | ||
} | ||
annotation class MockWebServerInstance( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a JUnit best practice? I don’t love having to define a metaprogramming API here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, but I can switch to Named?
https://www.vogella.com/tutorials/JUnit5Extensions/article.html
#fixes #7146
Takes a more opinionated view on lifecycle, namely.