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

Support TestLifecycleAware-ness of containers started by the JUnit Jupiter integration #1326

Merged
merged 41 commits into from Apr 12, 2020

Conversation

roamingthings
Copy link
Contributor

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.

@rnorth
Copy link
Member

rnorth commented Mar 19, 2019

Thanks @roamingthings - I'll add 'WIP' to the title to mark as a work-in-progress.

@rnorth rnorth changed the title Support TestLifecycleAware-ness of containers started by the JUnit Jupiter integration WIP: Support TestLifecycleAware-ness of containers started by the JUnit Jupiter integration Mar 19, 2019
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.
@stale
Copy link

stale bot commented Jun 25, 2019

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.

@stale stale bot added the stale label Jun 25, 2019
@roamingthings
Copy link
Contributor Author

Is this still WIP?

@stale stale bot removed the stale label Jun 25, 2019
@bsideup
Copy link
Member

bsideup commented Jun 25, 2019

@roamingthings you're the author, that's up to you :)

@roamingthings
Copy link
Contributor Author

You're right :) I will take another look at this issue when I'm back in Berlin.

@bsideup
Copy link
Member

bsideup commented Jul 19, 2019

@roamingthings ping :)

@bsideup bsideup modified the milestones: 1.12.5, next Jan 19, 2020
@roamingthings
Copy link
Contributor Author

@bsideup Maybe you can take another look at the changes. I've incorporated the changes you suggested.

)

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.
@roamingthings
Copy link
Contributor Author

@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.

@bsideup bsideup merged commit 84c8d1e into testcontainers:master Apr 12, 2020
@bsideup
Copy link
Member

bsideup commented Apr 12, 2020

@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 👍 💯

@roamingthings
Copy link
Contributor Author

That's great news 🥳
I also like the solution and how it developed very much 💯

@rnorth
Copy link
Member

rnorth commented Apr 13, 2020

This was released in https://github.com/testcontainers/testcontainers-java/releases/tag/1.14.0 🎉

Thanks for the contribution!

quincy referenced this pull request in quincy/testcontainers-java May 28, 2020
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants