Skip to content

Conversation

@Knud-Aage
Copy link
Contributor

Description:
This pull request migrates all test classes from TestNG to JUnit 5. The migration includes replacing TestNG-specific annotations and methods with their JUnit 5 equivalents. The migration of JAccept is still pending, and classes where JUnit 5 does not have a similar method should be reviewed more thoroughly.

Changes:
Migration of TestNG to JUnit 5:
Replaced TestNG annotations (@BeforeClass, @test, @tag, etc.) with JUnit 5 equivalents (@BeforeAll, @test, @tag, etc.).
Updated test lifecycle methods to use JUnit 5 annotations (@beforeeach, @AfterEach, @BeforeAll, @afterall).

Review of JUnit 5 Compatibility:
It will be appreciated if classes where JUnit 5 does not have a direct equivalent method is reviewed thoroughly. These classes have been updated to use appropriate JUnit 5 methods.

Pending JAccept Migration:
The migration of JAccept is still pending. The test classes have been updated to use JUnit 5 annotations and methods, but JAccept-specific methods and classes have not been replaced.

Removal of IntegrityWorkflowSchedulerTest.java:
Observed that IntegrityWorkflowSchedulerTest.java might be redundant and has been marked for removal. This class will be reviewed and removed if deemed unnecessary.

Detailed Changes:
Updated Annotations:
Replaced @BeforeClass with @BeforeAll.
Replaced @test with @test.
Replaced @groups with @tag.

Lifecycle Methods:
Updated test lifecycle methods to use JUnit 5 annotations (@beforeeach, @AfterEach, @BeforeAll, @afterall).

Pending JAccept Migration:
The migration of JAccept is still pending. The test classes have been updated to use JUnit 5 annotations and methods, but JAccept-specific methods and classes have not been replaced.

Removal of IntegrityWorkflowSchedulerTest.java:
Shouldn't IntegrityWorkflowSchedulerTest.java be removed from the project?. This class will be reviewed and removed if deemed unnecessary.

Review Request:
Please review the changes thoroughly. Specifically, pay attention to the classes where JUnit 5 does not have a direct equivalent method and ensure that the migration are correct and functional. In the master branch there are tests that fail, so the same tests probably will fail after migration. Migration of JAccept that will follow may also inflict on tests that fail, so the migration of the tests should at most amount in the same tests as in the master branch will fail. Also, review the removal of IntegrityWorkflowSchedulerTest.java and provide feedback on whether this class should be removed from the project.

- Added JUnit 5 annotations to BitrepositoryTestSuite
- Added GlobalSuiteExtension to implement JUnit 5 extension points for suite-level setup and teardown.
- Ensured consistency and correctness of test suite configuration and setup methods.

This commit updates the test suite configuration to use JUnit 5 annotations, allowing for more flexible and powerful test suite management.
…junit' into BITMAG-1244-junit-bitrepository-core

# Conflicts:
#	bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java
#	bitrepository-core/src/test/java/org/bitrepository/protocol/bus/ActiveMQMessageBusTest.java
#	bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusNumberOfListenersStressTest.java
…n install can't run because it gives errors in the module bitrepository-client, which hasn't been converted to junit 5 yet.
@Knud-Aage Knud-Aage self-assigned this Jan 14, 2026
<artifactId>junit-platform-suite-engine</artifactId>
<version>1.10.3</version> <!-- Match your JUnit version -->
<scope>test</scope>
</dependency> <dependency>
Copy link
Contributor

@ole-v-v ole-v-v Jan 15, 2026

Choose a reason for hiding this comment

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

Please break this line in the middle and fix the indentation of lines 189 to 195.

Copy link
Contributor

@ole-v-v ole-v-v left a comment

Choose a reason for hiding this comment

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

Nice work!

<artifactId>testng</artifactId>
<version>7.1.0</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this dependency? What for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're correct. Removed it.

Assertions.assertNull(model.getFileID());
Assertions.assertNull(model.getStartDate());
Assertions.assertNull(model.getCollectionID());
Assertions.assertEquals(model.getAscending(), ascending);
Copy link
Contributor

Choose a reason for hiding this comment

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

You have mostly remembered to swap arguments of assertEquals() and assertNotEquals(). Seems you forgot in some places throughout this pull request, like here and few more times in this file. IntelliJ IDEA correctly warns about it most of the times (at least mine does, I believe it’s a default setting). We have agreed that this can be fixed in a different pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found out that there it is possible to change everywhere that there is a warning in the project, so it should be done now.

return getClass().getSimpleName();
}

protected String createDate() {
Copy link
Contributor

Choose a reason for hiding this comment

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

The method does not seem to be used ever. Delete?

protected void shutdownCUT() {}

/**
* Initializes the settings. Will postfix the alarm and collection topics with '-${user.name}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicking, should the single quote be closed after the right curly brace?

Copy link
Contributor

Choose a reason for hiding this comment

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

If this file or parts of it are copy-pasted from somewhere and/or AI generated, please give the source in a comment.

protected static Settings settingsForCUT;
protected static Settings settingsForTestClient;
protected static String collectionID;
protected String NON_DEFAULT_FILE_ID;
Copy link
Contributor

Choose a reason for hiding this comment

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

Uppercase (screaming snake case) is reserved for constants, that is, variables that are static and final. So please either make the variable so or change the name. Same for other names in all uppercase.

/**
* May be overridden by specific tests wishing to do stuff. Remember to call super if this is overridden.
*/
protected void shutdownCUT() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be called, for example from afterAll()?

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.

3 participants