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

Migrate2junit5 #478

Merged
merged 14 commits into from
May 1, 2024
Merged

Migrate2junit5 #478

merged 14 commits into from
May 1, 2024

Conversation

ErhardSiegl
Copy link
Contributor

Migrate Tests from JUnit 4 to 5 with OpenRewrite

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason, why the versions is not managed in the dependency-management section of the parent pom?

public void setUpMethod() throws Exception {
Mockito.when(sensorCache.getByDeviceId(DEVICE_ID_NOTFOUND)).thenReturn(Optional.empty());
Mockito.when(sensorCache.getByDeviceId(DEVICE_GRUENER_GEPARD)).thenReturn(TestSensors.sensorGruenerGepard());
Mockito.lenient().when(sensorCache.getByDeviceId(DEVICE_ID_NOTFOUND)).thenReturn(Optional.empty());
Copy link
Contributor

Choose a reason for hiding this comment

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

Lenient would not be necessary if we make two @nested Test-Classes for each type

  • GruenerGepard
  • DeviceIdNotFound

Then the Mocks could be done for each class seperately.

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason, why the versions is not managed in the dependency-management section of the parent pom?

@@ -61,7 +58,7 @@ public void testDateUtilTimeOK() {
public void testDateUtilTimeNOKHour() {
try {
DateUtil.getTime(99, 0, 0);
assertTrue("IllegalArgumentException was not thrown.", false);
assertTrue(false, "IllegalArgumentException was not thrown.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should use assertThrows for this test and the following. This would increase readability.

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason, why the versions is not managed in the dependency-management section of the parent pom?

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason, why the versions is not managed in the dependency-management section of the parent pom?

@ErhardSiegl
Copy link
Contributor Author

Cleaned versions in POMs.

Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

121 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@ErhardSiegl
Copy link
Contributor Author

Fixed Checks.

@ErhardSiegl ErhardSiegl merged commit 8daf383 into master May 1, 2024
2 checks passed
@ErhardSiegl ErhardSiegl deleted the migrate2junit5 branch May 1, 2024 15:06
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.

2 participants