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

Framework-agnostic container & test lifecycle #702

Merged
merged 3 commits into from Jun 13, 2018
Merged

Conversation

bsideup
Copy link
Member

@bsideup bsideup commented May 17, 2018

See #87

Copy link
Member

@kiview kiview left a comment

Choose a reason for hiding this comment

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

Although it seems like a bigger change, the actual changes aren't that big and we aren't breaking any compatibiltiy I assume, so I think we can merge it soon?

@@ -0,0 +1,13 @@
package org.testcontainers.lifecycle;

public interface Startable extends AutoCloseable {
Copy link
Member

Choose a reason for hiding this comment

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

Why to we need this interface in this PR? It seems it's not used anyhwere (besides being implemented).
To use it in the testframework specific implementation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it defines a unified set of methods for both GenericContainer and DockerComposeContainer


import java.util.Optional;

public interface TestDescription {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we need all methods as the public interface.
The way BrowserWebDriverContainer works with it is kind of awkward, implementing the fallback if getFilesystemFriendlyName() is not implemented itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

What would you suggest? :)

Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense to not have getFilesystemFriendlyName in here, since it seems oddly use case specific?

Or if we want to make it convenient, we could maybe have the default implementation here?
return getNameParts().map(it -> String.join("-", it));
And then the default implementation of getNameParts() would also become

return Optional.of(new String[]{
                    getTestId()
                });

Copy link
Member Author

Choose a reason for hiding this comment

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

oddly use case specific

But we have this use case at least in one place.

default implementation

I don't think this is a good default implementation to be honest, I would rather keep it explicit and let framework adapters think about it, what's the best way to provide a FS friendly name of the test

Copy link
Member

Choose a reason for hiding this comment

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

What about omitting the default implementation completely then?

Copy link
Member Author

Choose a reason for hiding this comment

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

fine by me :)


public interface TestLifecycleAware {

default void beforeTestBlock(TestDescription description) {
Copy link
Member

Choose a reason for hiding this comment

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

Why beforeTestBlock and not beforeTest? What are the semantics of block?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just in case if some Test frameworks define Test as something more bigger and an atomic execution unit is some block of code. Arguable :)

Copy link
Member

Choose a reason for hiding this comment

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

I think I would prefer removing block in order to remove the ambiguity, but your explanation is also fine, so that's a IMO thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I summon @rnorth as a tiebreaker 😄

try {
imageName = image.get();
} catch (Exception e) {
imageName = "<unknown>";
Copy link
Member

Choose a reason for hiding this comment

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

I see it's just copied from the old implementation, but does this acutally happen?

Copy link
Member Author

Choose a reason for hiding this comment

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

well, to give you a bit of history here:

When I was implementing https://github.com/testcontainers/testcontainers-java/pull/106/files, we wanted to keep the backward compatibility as much as possible, and one of such is Logger based on image's name :)

@kiview
Copy link
Member

kiview commented Jun 12, 2018

I would be happy to merge this, then I could finish #726 without forcefully accessing protected JUnit methods 😆

Maybe @rnorth can have an additional look before merging?

@bsideup bsideup merged commit b333e29 into master Jun 13, 2018
@bsideup bsideup deleted the new_lifecycle branch June 13, 2018 21:03
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

3 participants