-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support TestLifecycleAware-ness of containers started by the JUnit Jupiter integration #1326
Support TestLifecycleAware-ness of containers started by the JUnit Jupiter integration #1326
Conversation
Allow containers like WebBrowserContainers to initialize and/or finalize before/after tests.
Thanks @roamingthings - I'll add 'WIP' to the title to mark as a work-in-progress. |
…leAware containers
This kind of test is a bit tricky since the post condition occurs after the original test has been finished. Also it's not nice to pass data between two tests.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this. |
Is this still WIP? |
@roamingthings you're the author, that's up to you :) |
You're right :) I will take another look at this issue when I'm back in Berlin. |
@roamingthings ping :) |
We want to use AssertJ for some tests.
...es/junit-jupiter/src/main/java/org/testcontainers/junit/jupiter/TestcontainersExtension.java
Outdated
Show resolved
Hide resolved
@bsideup Maybe you can take another look at the changes. I've incorporated the changes you suggested. |
...it-jupiter/src/main/java/org/testcontainers/junit/jupiter/TestcontainersTestDescription.java
Outdated
Show resolved
Hide resolved
...it-jupiter/src/main/java/org/testcontainers/junit/jupiter/TestcontainersTestDescription.java
Outdated
Show resolved
Hide resolved
) Generating a filesystem friendly name in a Junit Jupiter test is a bit tricky. Since tests can be generated dynamically class and/or test method may not be available. The display name provided by the ExtensionContext on the other hand may use characters that are not filesystem safe. This approach removes all characters from the display name that are not in a restricted set of allowed characters. However this may lead to name clashes if two tests have a display name that only differs in characters that are removed from the display name.
@bsideup This time a tried a different approach to generate the filesystem friendly name by removing illegal characters from the display name. However this could lead to clashes if two tests only differ in characters that are removed. |
...-jupiter/src/main/java/org/testcontainers/junit/jupiter/FilesystemFriendlyNameGenerator.java
Outdated
Show resolved
Hide resolved
@roamingthings 1 year after (omg!), we're happy to merge this PR 🎉 Sorry that it took so long, but I am super happy about the result 👍 💯 |
That's great news 🥳 |
This was released in https://github.com/testcontainers/testcontainers-java/releases/tag/1.14.0 🎉 Thanks for the contribution! |
…piter integration (#1326) * Update BrowserWebDriverContainer to honor existing no_proxy setting * Update test to only start one container per test * Use constant for no_proxy key * Cleanup test implementation (#929) * Add signalling of TestLifecycleAware containers. Allow containers like WebBrowserContainers to initialize and/or finalize before/after tests. * #1326 Add early draft to test signalling of TestLifecycleAware containers * Add test for post condition when signalling lifecycleaware containers This kind of test is a bit tricky since the post condition occurs after the original test has been finished. Also it's not nice to pass data between two tests. * Update test for lifecycle aware containers to cover shared case (#1326) In order to check that the afterAll callback has signalled lifecycleaware containers correctly a second extension is used. The order of the extension annotation ensures that the assertion is run after the extension under test. * Update test for lifecycle aware containers to cover shared case (#1326) To test the beforeAll() case the assertion has to be called from within the test class since it's called after all extensions. * Fix formatting (#1326) * Use lighter container for testing (#1326) * Separate store and collect of shared lifecycle-aware-containers (#1326) * Add tests for ordering and capturing test exceptions (#1326) * Make lifecycle tests independent of timing (#1326) Calls to the lifecycle methods are now recorded in an ordered list that is then used to test the correct number and order of calls. This makes the test independent of timing. Unfortunately it's still required to execute tests in a deterministic order. For a better separation of test concerns tests for the lifecycle methods and exception capturing have been moved into separate test classes. * Make mock now implements Startable (#1326) There is no need to start a container since only the TestLifecycleAware is important. * Add AssertJ dependency (#1326) We want to use AssertJ for some tests. * Migrate assertions of TestLifecycleAwareMethodTest to AssertJ (#1326) * Update generation of filesystem friendly description (#1326) * Separated tests for filesystem friendly filename (#1326) * Use lombok to improve readability (#1326) * Generate filesystem friendly name from display name (#1326) Generating a filesystem friendly name in a Junit Jupiter test is a bit tricky. Since tests can be generated dynamically class and/or test method may not be available. The display name provided by the ExtensionContext on the other hand may use characters that are not filesystem safe. This approach removes all characters from the display name that are not in a restricted set of allowed characters. However this may lead to name clashes if two tests have a display name that only differs in characters that are removed from the display name. * Generate filesystem friendly name from URLEncoded unique id (#1326) Co-authored-by: Richard North <rich.north@gmail.com> Co-authored-by: Kevin Wittek <kiview@users.noreply.github.com>
Allow containers like WebBrowserContainers to initialize and/or finalize
before/after tests.
This is a proof of concept kind of implementation.
A test is also missing.