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

Fix lifecycle for Junit 5 extension. #7392

Merged
merged 10 commits into from Aug 16, 2022
Merged

Fix lifecycle for Junit 5 extension. #7392

merged 10 commits into from Aug 16, 2022

Conversation

yschimke
Copy link
Collaborator

@yschimke yschimke commented Jul 24, 2022

#fixes #7146

Takes a more opinionated view on lifecycle, namely.

@yschimke yschimke requested a review from swankjesse July 24, 2022 12:31
@yschimke yschimke marked this pull request as draft July 24, 2022 13:09
@yschimke yschimke marked this pull request as ready for review August 15, 2022 16:36
@yschimke
Copy link
Collaborator Author

@swankjesse requesting post review. Reviews from anyone else very welcome, especially on Junit5 usage.

Copy link
Member

@swankjesse swankjesse left a 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 {
Copy link
Member

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(
Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

MockWebServer extension is starting new server when I call @BeforeEach and @AfterEach
2 participants