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: aligns lifecycle calls in JUnit 5 with JUnit 4 behavior #310

Merged
merged 1 commit into from
Feb 23, 2021

Conversation

lprimak
Copy link
Contributor

@lprimak lprimak commented Feb 8, 2021

  • @BeforeAll / @afterall callbacks are always called on the client, consistent with JUnit 4 behavior
  • restored calls to @beforeeach / @AfterEach in client mode, were only being called on the server

Short description of what this resolves:

Fixes problems encountered in #288 and #301
Fixes #309

Note: Use "ignore whitespace changes" to review

@lprimak
Copy link
Contributor Author

lprimak commented Feb 8, 2021

@bartoszmajsak Can you review this please?
Thank you!

@bartoszmajsak
Copy link
Member

Thanks @lprimak! Merging #301 was giving me a bit of mixed feeling seeing this without any tests, but here we are :) I wonder though - do you think we could add some of the reproducers you created (and maybe more tests as we evolve) to be part of repo/build? This way we can avoid such challenges going forward.

invocation.skip();
} else {
invocation.proceed();
Copy link
Member

Choose a reason for hiding this comment

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

Why are we reversing the logic here? We don't want to have @BeforeAll executed as Arquillian test?

Copy link
Contributor

@dmatej dmatej Feb 8, 2021

Choose a reason for hiding this comment

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

Seems to me we are going backwards to the same issue we had two years back - it depends. It makes sense for both use cases, sometimes.

I think we need another annotation for this and decide what should be the default - run on the client side or on the server side? And warn before undefined order if both variants combined (multiple BeforeEach annotated methods). Maybe if RunAsClient is used, default should be just the remote side, if not, the opposite. But even then it makes sense in the other way.

Or am I wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not the same case David :). This is the simplest case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bartoszmajsak the logic is reversed to accomplish the fix for the issue. These methods have to be only executed on the client and not in container as they are executed that way in JUnit 4

I’ll try to add the test for this as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added the tests. However, they are excluded for now. This requires integration test setup with app server as far as I am aware, and it's not done in Arquillian just yet, so I am not sure how to introduce that kind of tests.
Saying that, it's there and works when enabled :)

@lprimak
Copy link
Contributor Author

lprimak commented Feb 8, 2021

@bartoszmajsak added tests

@lprimak lprimak requested a review from bartoszmajsak February 8, 2021 17:48
@lprimak
Copy link
Contributor Author

lprimak commented Feb 9, 2021

Thanks @lprimak! Merging #301 was giving me a bit of mixed feeling seeing this without any tests, but here we are :) I

Well, the change was so simple :)
Also since there were no tests originally for client invocations, and we obviously didn't know that it was the client that would break, they would not have helped :)
Also it's not at all clear that the behavior in JUnit4 container is correct as @dmatej says.

However, with this PR, status quo is maintained and nothing is broken, so there's that...

Copy link
Member

@bartoszmajsak bartoszmajsak left a comment

Choose a reason for hiding this comment

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

Few minor points I wanted to raise with you before we can move this forward.

P.S. I've been away from the keyboard the whole last week hence the silence.

Comment on lines 46 to 61
<!-- This is commented out because it is not set up to run
with current Arquillian testing environment-->
<!-- JUnit 5 Container / Payara support -->
<!-- <dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>fish.payara.arquillian</groupId>
<artifactId>arquillian-payara-server-remote</artifactId>
<version>2.3.3</version>
<scope>test</scope>
</dependency>-->

Copy link
Member

@bartoszmajsak bartoszmajsak Feb 10, 2021

Choose a reason for hiding this comment

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

If not needed then let's remove it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will put the new tests into another PR so you can decide what to do with them, and remove from this PR.
@kifj has ported tests so now this code is tested - thank you!
Above can move this PR forward

junit5/core/pom.xml Outdated Show resolved Hide resolved
junit5/core/pom.xml Outdated Show resolved Hide resolved
@lprimak lprimak force-pushed the FixLifecycleCallbacks branch from 07b050a to c50018a Compare February 23, 2021 03:08
        - @BeforeAll / @afterall callbacks are always called on the client, consistent with JUnit 4 behavior
        - restored calls to @beforeeach / @AfterEach in client mode, were only being called on the server
@lprimak
Copy link
Contributor Author

lprimak commented Feb 23, 2021

@bartoszmajsak ready to go!

@bartoszmajsak bartoszmajsak changed the title Fixed lifecycle calls in JUnit 5 fix: aligns lifecycle calls in JUnit 5 with JUnit 4 behavior Feb 23, 2021
@bartoszmajsak bartoszmajsak merged commit 17963c1 into arquillian:master Feb 23, 2021
@lprimak lprimak deleted the FixLifecycleCallbacks branch February 23, 2021 08:27
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.

1.7.0.Alpha7 does not call JUnit lifecycle hooks?
3 participants