Skip to content

Bitmag 1244 testng junit all asga#75

Open
Knud-Aage wants to merge 43 commits intomasterfrom
BITMAG-1244-testng-junit-all-asga
Open

Bitmag 1244 testng junit all asga#75
Knud-Aage wants to merge 43 commits intomasterfrom
BITMAG-1244-testng-junit-all-asga

Conversation

@Knud-Aage
Copy link
Contributor

This Pull Request migrates the existing TestNG-based test architecture to JUnit 5. The primary focus has been on establishing a correct suite lifecycle, ensuring test independence, and implementing explicit resource handling for Pillars and the Message Bus.
Additionally, this PR includes significant stability improvements to ensure all tests pass reliably, specifically addressing networking conflicts in the Message Bus stress tests.

Key Changes

  1. JUnit 5 Migration
    • Framework Replacement: Replaced TestNG dependencies and annotations with JUnit 5 (Jupiter).
    • Annotation Updates: Converted @test, @BeforeClass, @afterclass, etc., to their JUnit 5 equivalents (@test, @BeforeAll, @afterall, @beforeeach).

  2. Architecture & Lifecycle (JIRA Scope)
    • Suite Lifecycle: Moved away from TestNG's implicit suite lifecycle via inheritance. Implemented JUnit 5 Extensions (@ExtendWith, @RegisterExtension) to handle heavy shared resources like Pillars and the Message Bus.
    Ensured Pillars and Message Bus are initialized deterministically.
    ◦ Fixed issues where the Message Bus was initialized multiple times or destroyed too early.
    ◦ Decoupled infrastructure setup from test logic to support independent test execution.

  3. Test Stability & Fixes
    • Robust Teardown: Enhanced try-finally blocks in stress tests to ensure broker.stop() and listener.stop() are called even if assertions fail, preventing zombie processes and resource leaks.
    • Concurrency Handling: Updated synchronization logic in stress tests to wait for message processing without relying on deprecated threading models.
    • Addressed the fundamental difference between TestNG's stateful/ordered testing and JUnit 5's stateless/independent testing. Tests are now designed to run in isolation without assuming execution order.
    • Extensions vs. Inheritance: Migrated suite hooks from base classes to JUnit 5 Extensions to separate global lifecycle concerns from individual test case logic.
    • All unit and integration tests now pass.

- 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.
ole-v-v

This comment was marked as off-topic.

ole-v-v

This comment was marked as off-topic.

ole-v-v

This comment was marked as off-topic.

beforeWorkflowDate.getTime() + " == "+ afterWorkflowDate.getTime());
Date afterWorkflowDate = csCache.getCalculationDate(defaultFileId, collectionID);

Assertions.assertEquals(afterWorkflowDate.getTime(), beforeWorkflowDate.getTime(), beforeWorkflowDate.getTime() + " == " + afterWorkflowDate.getTime());
Copy link
Contributor

Choose a reason for hiding this comment

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

Swap back and also break line. The afterWorkflowDate is being validated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Swapped

ole-v-v

This comment was marked as off-topic.

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