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

Add initial implementation of JUnit Jupiter Extension (#3662) #4351

Closed
wants to merge 1 commit into from
Closed

Add initial implementation of JUnit Jupiter Extension (#3662) #4351

wants to merge 1 commit into from

Conversation

lordjaxom
Copy link

Fix #3662

We are using this initial implementation in our internal projects successfully with JUnit Jupiter 5.2+. It provides a JUnit Jupiter Extension (and annotation) that sets up and configures the Jersey Test Framework and is able to inject Client, WebTarget and URI instances into fields and/or test method parameters.

ECA is signed.

Signed-off-by: Sascha Volkenandt [email protected]

@DNAlchemist
Copy link

Is there any progress with this PR?

@sparsick
Copy link

This PR would help a lot of writing Jersey tests with Junit5. Maybe @jansupol or @senivam can have a look?

@jbescos
Copy link
Member

jbescos commented Jul 12, 2021

I created another PR. I was not aware of this. Here is my PR:
#4824

I found the only issue is that there are 2 methods annotated with @after and @before in JerseyTest. Those methods are not invoked in JUnit5 because it has other annotations for this (@AfterEach and @beforeeach)

In my opinion we only need to add those new annotations together with the Junit4 ones. This does not throw runtime errors when JUnit5 is not in the classpath.

@lordjaxom
Copy link
Author

@jbescos I think the two PRs are mostly unrelated. Enabling JerseyTest to work with JUnit 5 does not provide a JUnit-Extension, which is IMO preferable to having a test class extend JerseyTest. But the extension only provides an additional (more JUnit-y) approach to launching the Jersey Testframework.

Copy link
Member

@jbescos jbescos left a comment

Choose a reason for hiding this comment

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

The logic looks good to me.

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.5.2</version>
Copy link
Member

Choose a reason for hiding this comment

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

We can use here: ${junit5.version}

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.14.0</version>
Copy link
Member

Choose a reason for hiding this comment

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

It is preferable to create a property in pom.xml and reference that property here with ${assert.version}

<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Date needs to be the date of this was added in a commit. It should look like '2019, 2021'

There is a plugin that will fail in case it is not set correctly.

@@ -0,0 +1,145 @@
/*
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

2019, 2021

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

2019, 2021

@@ -0,0 +1,171 @@
/*
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

2019, 2021

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

2019, 2021

@@ -38,6 +38,7 @@
<module>util</module>
<module>maven</module>
<module>memleak-test-common</module>
<module>jupiter-extension</module>
Copy link
Member

Choose a reason for hiding this comment

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

You have to update the copyright date. This time it has to be: 2010, 2021

@lordjaxom lordjaxom closed this by deleting the head repository Feb 3, 2024
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.

JerseyTest is not compatible with JUnit 5
5 participants