RFR: 8339512: [TestBug] Convert graphics tests to JUnit 5
Lukasz Kostyra
lkostyra at openjdk.org
Wed Sep 18 15:24:53 UTC 2024
This PR converts all tests in `modules/javafx.graphics` to use JUnit5.
## Details
Trivial changes resolved by first four commits:
- Import changes to use `org.junit.jupiter` package instead of `org.junit` or `junit.framework` and all changes that follow it (ex. `@Before` -> `@BeforeEach`)
- Message Strings in `assert*` calls moved to the end to follow 5's argument order
- Some simple Parametrized tests (aka. those which only did a straightforward assignment of test parameters) adjusted to use JUnit5's `@ParametrizedTest` and `@MethodSource` annotations
- Some test formatting unification - keeping annotations on a separate line from method definition
Non-trivial changes:
- Mutliple tests use common test bases and derive from it to check specific behaviors. Those include:
- `DirtyRegionTestBase`
- `CssMethodsTestBase`
- `ObjectMethodsTestBase`
- `OnInvalidateMethodsTestBase`
- `PropertiesTestBase`
- `ServiceTestBase` & derivatives required some rework due to `ServiceExceptionTest` being a derived parametrized class while other `ServiceTestBase` were not parametrized
- `TransformOperationsTest` not only expanded 3 test parameters onto 6 different test class members, but also exposed its `getParams()` call to other testers - `AffineOperationsTest` and `TransformUtilsTest`
- Other classes used `@BeforeEach` annotation which accessed test parameters, that one had to be done separately
At the end I added a change converting `assertTimeout` uses I added to `@Timeout` annotation, as recommended in other PRs.
## Results
Below are results of the test conversion and runs of `gradle --info :graphics:test` on my machine:
| Category | JUnit4 ( 4647367ce ) | JUnit5 (this PR) |
| ------------ | ------ | ------ |
| Test count | 23272 | 23275 |
| Failures | 0 | 0 |
| Ignored | 99 | 102 |
| Successful % | 100% | 100% |
The difference in test count and ignored comes from `Popup_parentWindow_Test.java` where the entire test class was annotated as `@Ignored`. After conversion, the `@Disabled` annotation applies to each test individually rather than the whole class, so:
Popup_parentWindow_Test. initializationError
becomes
Popup_parentWindow_Test. testBasicAccess(Configuration)
Popup_parentWindow_Test. testBinding(Configuration)
Popup_parentWindow_Test. testGetBean(Configuration)
Popup_parentWindow_Test. testGetName(Configuration)
Outside of that, the ignore list matches between both runs. I did not notice any regressions or other differences in test execution.
-------------
Commit messages:
- Use @Timeout annotation instead of assertTimeout
- Convert remaining non-trivial tests to JUnit5
- Convert graphics tests to JUnit5 - part 4/4
- Convert graphics tests to JUnit5 - part 3/4
- Convert graphics tests to JUnit5 - part 2/4
- Convert graphics tests to JUnit5 - part 1/4
Changes: https://git.openjdk.org/jfx/pull/1566/files
Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1566&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8339512
Stats: 14465 lines in 410 files changed: 4658 ins; 2102 del; 7705 mod
Patch: https://git.openjdk.org/jfx/pull/1566.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/1566/head:pull/1566
PR: https://git.openjdk.org/jfx/pull/1566
More information about the openjfx-dev
mailing list