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

Migrate resolver tests in o.e.osgi.tests to JUnit 4 #455

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

HeikoKlare
Copy link
Contributor

This migrates all tests in org.eclipse.osgi.tests.resolver and org.eclipse.osgi.tests.services.resolver to JUnit 4

  • Add JUnit 4 annotations @Test, @Before, @After
  • Remove inheritance of JUnit 3 TestCase and CoreTest
  • Replace try-catch for actual errors with making the test method throw the exception

Comment on lines +103 to +108
private void fail(String message, Throwable exception) {
AssertionFailedError error = new AssertionFailedError(message);
error.initCause(exception);
throw error;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fyi: this is a reduced version of the method that was inherited from CoreTest before. I kept it instead of replacing all the fail calls as the exceptions in those cases are part of the functionality-under-test, so they should make the test fail rather than error on occurrence (see #453 (comment)).

Copy link

github-actions bot commented Dec 22, 2023

Test Results

   25 files  ±0     25 suites  ±0   10m 55s ⏱️ -6s
2 156 tests ±0  2 110 ✅  - 1  46 💤 +1  0 ❌ ±0 
2 200 runs  ±0  2 154 ✅  - 1  46 💤 +1  0 ❌ ±0 

Results for commit 7ee4201. ± Comparison against base commit fa054eb.

This pull request skips 1 test.
org.eclipse.osgi.tests.services.datalocation.BasicLocationTests ‑ testUNC

♻️ This comment has been updated with latest results.

public void testCreateLocation04() {
Location configLocation = configLocationTracker.getService();
File testLocationFile = OSGiTestsActivator.getContext().getDataFile("testLocations/testCreateLocation04");
Location testLocation = configLocation.createLocation(null, null, true);
try {
testLocation.set(testLocationFile.toURL(), true);
testLocation.release();
fail("Should not be able to lock read-only location");
Assert.fail("Should not be able to lock read-only location");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could not be replaced with an assertThrows as this test actually fails silently, see #460

@HeikoKlare
Copy link
Contributor Author

This pull request skips 1 test.

org.eclipse.osgi.tests.services.datalocation.BasicLocationTests ‑ testUNC

Skipped test is because the conditional return was replaced with a JUnit 4 assume statement.

@HeikoKlare HeikoKlare marked this pull request as ready for review December 22, 2023 17:36
This migrates all tests in org.eclipse.osgi.tests.resolver and
org.eclipse.osgi.tests.services.resolver to JUnit 4

* Add JUnit 4 annotations @test, @before, @after
* Remove inheritance of JUnit 3 TestCase and CoreTest
* Replace try-catch for actual errors with making the test method throw
the exception
@akurtakov akurtakov merged commit 03533f1 into eclipse-equinox:master Jan 12, 2024
23 of 24 checks passed
@HeikoKlare HeikoKlare deleted the junit4-resolver branch January 12, 2024 17:12
@HannesWell
Copy link
Member

Thank you Alex for taking over and of course to Heiko.

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