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

Update to JUnit5 #10793

Closed
14 tasks done
MartinWahnschaffe opened this issue Oct 30, 2022 · 1 comment · Fixed by #10819 or #10947
Closed
14 tasks done

Update to JUnit5 #10793

MartinWahnschaffe opened this issue Oct 30, 2022 · 1 comment · Fixed by #10819 or #10947
Assignees
Labels
backend Affects the web backend change A change of an existing feature (ticket type) technology Technical issues, e.g. synchronization, libraries, plugins, etc. testing Issues that enable or extend testing of the application vaadin-app Affects the Vaadin application

Comments

@MartinWahnschaffe
Copy link
Contributor

MartinWahnschaffe commented Oct 30, 2022

Problem Description

JUnit5 is out since 2017 and brings the following benefits:

  • we get more granularity, and can import only what's necessary
  • JUnit 5 allows multiple runners to work simultaneously
  • JUnit5 allows Java8+ language features like lambda functions, making tests more powerful and easier to maintain.
  • new features for describing, organizing, and executing tests. For instance, tests get better display names and can be organized hierarchically (e.g. https://medium.com/@boonkeat/android-unit-testing-with-junit5-d1b8f9c620b6)
  • Allows combination of multiple extensions

Furthermore JUnit5 gives us more freedom of choice and comfort related to replacing our CDI unit testing framework.
See #10074 (comment)

Proposed Change

Update to JUnit5. This means replacing imports and few clean ups.
The whole process should be done in one step.
Check whether Android app should be updated as-well or separately. -> Separately

Acceptance Criteria

Implementation Details

  • org.unit.Test -> org.junit.jupiter.api.Test
  • org.junit.Assert.* -> org.junit.jupiter.api.Assertions.*
  • org.junit.Assert.assertThat -> org.hamcrest.MatcherAssert.assertThat
  • Before -> BeforeEach
  • BeforeClass -> BeforeAll
  • After -> AfterEach
  • ArchUnitRunner no longer needed
  • Test(expected=Exception) -> assertThrows
  • Some assertions currently have string message first -> is last param instead now
  • Use latest WireMock version for Junit5
  • CaseFacadeEjbTest: Extract wire mock related tests
  • TestContainers Junit5 extension + workaround: GenericContainer run from Jupiter tests shouldn't require JUnit 4.x library on runtime classpath testcontainers/testcontainers-java#970 (comment)
  • Move tests for external surveillance functionality from CaseServiceTest and EventServiceTest into ExternalSurveillanceToolGatewayFacadeEjbTest
  • Remove sharing logic from testArchive... test in CaseFacadeEjbTest and EventFacadeEjbTest

Additional Information

@MartinWahnschaffe MartinWahnschaffe added backend Affects the web backend vaadin-app Affects the Vaadin application technology Technical issues, e.g. synchronization, libraries, plugins, etc. testing Issues that enable or extend testing of the application change A change of an existing feature (ticket type) rest labels Oct 30, 2022
@MartinWahnschaffe MartinWahnschaffe self-assigned this Nov 1, 2022
@MartinWahnschaffe MartinWahnschaffe moved this from Backlog to In Progress in SORMAS Team 2 - DEV - Iteration Backlog Nov 1, 2022
MartinWahnschaffe added a commit that referenced this issue Nov 2, 2022
org.unit.Test -> org.junit.jupiter.api.Test
org.junit.Assert.* -> org.junit.jupiter.api.Assertions.*
org.junit.Assert.assertThat -> org.hamcrest.MatcherAssert.assertThat
Before -> BeforeEach
BeforeClass -> BeforeAll
After -> AfterEach
ArchUnitRunner no longer needed
Test(expected=Exception) -> assertThrows
Some assertions currently have string message first -> is last param instead now
Use latest WireMock version for Junit5
CaseFacadeEjbTest: Extract wire mock related tests
TestContainers Junit5 extension + workaround: testcontainers/testcontainers-java#970 (comment)
Move tests for external surveillance functionality from CaseServiceTest and EventServiceTest into ExternalSurveillanceToolGatewayFacadeEjbTest
Remove sharing logic from testArchive... test in CaseFacadeEjbTest and EventFacadeEjbTest
@StefanKock StefanKock removed the rest label Nov 3, 2022
@StefanKock StefanKock moved this from In Progress to Review in SORMAS Team 2 - DEV - Iteration Backlog Nov 3, 2022
MartinWahnschaffe added a commit that referenced this issue Nov 4, 2022
SORMAS Team 2 - DEV - Iteration Backlog automation moved this from Review to Testing Nov 4, 2022
@StefanKock StefanKock added this to the Sprint 120 - 1.77.0 milestone Nov 8, 2022
@StefanKock
Copy link
Contributor

While working on #10801 I noticed that StartupShutdownServiceTest has a compile error in my Eclipse because testcontainers still relies on JUnit 4: The type org.junit.runner.Description cannot be resolved. It is indirectly referenced from required .class files

I tried @SuppressWarnings("all") but that did not help. On Jenkins the test testHistoryTablesMatch runs successfully (33s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Affects the web backend change A change of an existing feature (ticket type) technology Technical issues, e.g. synchronization, libraries, plugins, etc. testing Issues that enable or extend testing of the application vaadin-app Affects the Vaadin application
Projects
None yet
2 participants