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

RunTestOnContext for JUnit 5 #100

Closed
DavideD opened this issue Mar 24, 2021 · 10 comments · Fixed by #109
Closed

RunTestOnContext for JUnit 5 #100

DavideD opened this issue Mar 24, 2021 · 10 comments · Fixed by #109
Assignees
Milestone

Comments

@DavideD
Copy link

DavideD commented Mar 24, 2021

There is this rule available for JUnit 4:

	@Rule
	public RunTestOnContext vertxContextRule = new RunTestOnContext();

It would be nice to have something similar for JUnit 5.
Probably an extension.

@DavideD DavideD added the enhancement New feature or request label Mar 24, 2021
@DavideD DavideD changed the title RunTestOnContest for JUnit 5 RunTestOnContext for JUnit 5 Mar 24, 2021
@vietj vietj added this to the 4.0.4 milestone Mar 25, 2021
@vietj vietj added help wanted enhancement and removed enhancement New feature or request labels Mar 25, 2021
@jponge
Copy link
Member

jponge commented Mar 25, 2021

Good idea @DavideD, would you like to try to contribute it?

@DavideD
Copy link
Author

DavideD commented Mar 25, 2021

I can try but I might need some help.
Can I copy the logic in Vert.x RunTestOnContext?
It seems it delegates some things to the VertxUnitRunner, should I do something similar and call the methods in VertxExtension?

@jponge
Copy link
Member

jponge commented Mar 26, 2021

I think yes you can copy or take inspiration from what's been done there.

@vietj vietj modified the milestones: 4.1.0, 4.1.1 Jun 1, 2021
@vietj
Copy link
Member

vietj commented Jun 3, 2021

@DavideD any progress on this contribution?

@DavideD
Copy link
Author

DavideD commented Jun 3, 2021

No, sorry. I didn't have time

@tsegismont
Copy link
Contributor

jUnit5 has a mechanism for intercepting test method calls.

This could be used to get a Vert.x context then run the test on this context.

@jponge the jUnit5 documentation says checkpoints shouldn't be used on Vert.x threads. Can you explain why?

This could be a problem if running tests on a Vert.x context.

@jponge
Copy link
Member

jponge commented Aug 27, 2021

That might be a bad explanation in the docs then, can you please point me to the corresponding sentence?

@tsegismont
Copy link
Contributor

https://vertx.io/docs/vertx-junit5/java/#_checkpoint_when_there_are_multiple_success_conditions

TIP: Checkpoints should be created only from the test case main thread, not from Vert.x asynchronous event callbacks.

@jponge
Copy link
Member

jponge commented Aug 27, 2021

Makes sense.

Checkpoints shall be created from the test main thread (e.g., when you enter a test method).

Then checkpoints shall be used from anywhere else (e.g., flagging from a callback).

This is because we had some users who created new checkpoints on the fly, like in the middle of a callback, but the main test context had already completed because it could not have anticipated that they would even exist.

@tsegismont
Copy link
Contributor

Ok. Perhaps we should change the tip wording then, it is confusing.

@tsegismont tsegismont self-assigned this Aug 30, 2021
tsegismont added a commit to tsegismont/vertx-junit5 that referenced this issue Sep 14, 2021
Closes eclipse-vertx#100

vertx-unit has a RunTestOnContext rule that had no equivalent in vertx-junit5.

Signed-off-by: Thomas Segismont <tsegismont@gmail.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 a pull request may close this issue.

4 participants