Skip to content

Conversation

jonahgraham
Copy link
Contributor

Because most all the tests remaining tests are in huge class hierarchy under Test_org_eclipse_swt_widgets_Widget they all need changing at once. The tests that are not under Test_org_eclipse_swt_widgets_Widget are generally pretty small, so included here to fully remove JUnit4 dependency.

This means that junit-vintage-engine and org.junit removed from Require-Bundle of the manifest.

Messages have been removed from assertions that didn't add value. The order of parameters to assertEquals and others changed, and for most of the calls I removed the message based on previous guidance. I tried to leave in messages that were more useful for documenting or diagnosing errors. But I removed messages that more or less repeated as a string what the item being tested is.

A lot of things work quite differently in JUnit5. Here are some highlights that have affected or benefited this change:

There is a better way of integrating screenshots into failed tests as tests can be intercepted between the test completion and the @AfterEach methods. Therefore we can take a screenshot prior to disposal, and then let the tear down message cleanup in a less convoluted way. See Test_org_eclipse_swt_widgets_Widget.afterTestExecutionCallback and tearDown methods to see this in action.

The way to get a test name is quite different. Instead of a TestName @Rule a TestInfo can be obtained. The name returned is not exactly the same format, but where the name needed a specific format, I adjusted the code appropriately. See Test_org_eclipse_swt_browser_Browser.testInfo and Test_org_eclipse_swt_widgets_Widget.testInfo for a couple of use cases.

Whole class parameterized tests don't really exist in a simple way in JUnit5. As there was very little use of this, rather than having complicated setup, I used sub-classes to provide the parameterization. See for example Test_org_eclipse_swt_widgets_DateTime and its new subclasses.

@jonahgraham
Copy link
Contributor Author

There are a couple of independent changes pulled out into PR #2591 and #2592 that I identified while refactoring the tests.

Copy link
Contributor

github-actions bot commented Oct 4, 2025

Test Results

  118 files  ±0    118 suites  ±0   13m 19s ⏱️ + 2m 31s
4 583 tests ±0  4 547 ✅ ±0  36 💤 ±0  0 ❌ ±0 
  330 runs  ±0    307 ✅ ±0  23 💤 ±0  0 ❌ ±0 

Results for commit eb57c00. ± Comparison against base commit 12ac449.

This pull request removes 706 and adds 706 tests. Note that renamed tests count towards both.
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback[browser flags: 524,288]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_afterPageReload[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_afterPageReload[browser flags: 524,288]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_stackedCalls[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_stackedCalls[browser flags: 524,288]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_with_String[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_with_String[browser flags: 524,288]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_with_boolean[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_with_boolean[browser flags: 524,288]
…
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_afterPageReload
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_stackedCalls
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_with_String
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_with_boolean
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_with_integer
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_with_javaReturningInt
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_with_javaReturningString
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_callback_with_multipleValues
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_BrowserFunction_multiprocess
…
This pull request removes 4 skipped tests and adds 4 skipped tests. Note that renamed tests count towards both.
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_Constructor_multipleInstantiationsInDifferentThreads[browser flags: 524,288]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_TabTraversalOutOfBrowser[browser flags: 0]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_TabTraversalOutOfBrowser[browser flags: 524,288]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_setForegroundAlphaLorg_eclipse_swt_graphics_Color[browser flags: 524,288]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser ‑ test_TabTraversalOutOfBrowser
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser_IE ‑ test_Constructor_multipleInstantiationsInDifferentThreads
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser_IE ‑ test_TabTraversalOutOfBrowser
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser_IE ‑ test_setForegroundAlphaLorg_eclipse_swt_graphics_Color

♻️ This comment has been updated with latest results.

@jonahgraham
Copy link
Contributor Author

In addition to the top comment, there are a few reasons I would like to get this integrated if there are no objections.

  1. Consistency - I have found it annoying to go between different classes and have to use different annotations/etc. Its pretty easy to mess things up because of using a JUnit4 annotation in a JUnit5 test and vice versa. By removing JUnit4 entirely that problem goes away.
  2. I want to be able to use @Tags, like what I described in [GTK4] Implement Full Clipboard support for GTK4 #2126 (comment)
  3. JUnit6 just came out this week - so we will presumably start migrating to that at some point. I think it would be nice to have at most 2 versions of JUnit co-existing instead of 3

@jonahgraham jonahgraham marked this pull request as ready for review October 4, 2025 02:48
@jonahgraham
Copy link
Contributor Author

jonahgraham commented Oct 4, 2025

TL;DR

The overall test counts look correct to me, this PR has expected number tests on Jenkins runs compared to latest master


The discovered test count has gone up a lot because of how I migrated the parameterized browser test. This means all the IE tests are marked as skipped on non-Windows platform instead of simply not existing in the test report. This increases the test count by 194 (The number of browser tests), which can be seen as the difference in total tests from latest master and this PR. On those same links you can see the total number of tests that pass is the same (4196).

I had originally identified a coupe of tests that were not running when I did the migration. See new @Test annotation on Test_org_eclipse_swt_widgets_Shell.test_setLocationLorg_eclipse_swt_graphics_Point(), Test_org_eclipse_swt_widgets_Shell.test_setLocationII(), and Test_org_eclipse_swt_browser_Browser.test_ConstructorLorg_eclipse_swt_widgets_CompositeI() - without those new annotations those tests were not running in JUnit5 but were in JUnit4.

@akurtakov
Copy link
Member

Thanks Jonah! I have been converting tests one by one for quite some time with this being the end goal - thanks for bringing it to closure.

@akurtakov
Copy link
Member

I am not thrilled by the new classes that used to be parametrized tests but I don't have better idea for now. Other than the *.orig file included by mistake it looks good to me.

Because most all the tests remaining tests are in huge class hierarchy
under Test_org_eclipse_swt_widgets_Widget they all need changing
at once. The tests that are not under Test_org_eclipse_swt_widgets_Widget
are generally pretty small, so included here to fully remove JUnit4
dependency.

This means that junit-vintage-engine and org.junit removed from
Require-Bundle of the manifest.

Messages have been removed from assertions that didn't add value.
The order of parameters to assertEquals and others changed, and for most
of the calls I removed the message based on previous guidance. I
tried to leave in messages that were more useful for documenting or
diagnosing errors. But I removed messages that more or less repeated
as a string what the item being tested is.

A lot of things work quite differently in JUnit5. Here are some highlights
that have affected or benefited this change:

There is a better way of integrating screenshots into failed tests as
tests can be intercepted between the test completion and the `@AfterEach`
methods. Therefore we can take a screenshot prior to disposal, and
then let the tear down message cleanup in a less convoluted way. See
Test_org_eclipse_swt_widgets_Widget.afterTestExecutionCallback and
tearDown methods to see this in action.

The way to get a test name is quite different. Instead of a TestName
`@Rule` a `TestInfo` can be obtained. The name returned is not exactly
the same format, but where the name needed a specific format, I adjusted
the code appropriately. See Test_org_eclipse_swt_browser_Browser.testInfo
and Test_org_eclipse_swt_widgets_Widget.testInfo for a couple of use
cases.

Whole class parameterized tests don't really exist in a simple way in
JUnit5. As there was very little use of this, rather than having complicated
setup, I used sub-classes to provide the parameterization. See for
example Test_org_eclipse_swt_widgets_DateTime and its new subclasses.
@jonahgraham
Copy link
Contributor Author

Thanks Jonah! I have been converting tests one by one for quite some time with this being the end goal - thanks for bringing it to closure.

Thanks for leading the way on that (and looking through the history on doing the 3 -> 4 migration too!). I was only wanting to do StyledText, but things ballooned because of the huge hierarchy of tests.

@jonahgraham
Copy link
Contributor Author

Is this ok to merge now?

@akurtakov
Copy link
Member

Yes it i. Merging.

@akurtakov akurtakov merged commit c3df782 into eclipse-platform:master Oct 4, 2025
17 checks passed
@jonahgraham jonahgraham deleted the junit5 branch October 6, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants