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 ResourceTests to JUnit 4/5 #903

Open
3 of 4 tasks
HeikoKlare opened this issue Nov 30, 2023 · 2 comments
Open
3 of 4 tasks

Migrate ResourceTests to JUnit 4/5 #903

HeikoKlare opened this issue Nov 30, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request test junit test related things

Comments

@HeikoKlare
Copy link
Contributor

HeikoKlare commented Nov 30, 2023

The ResourceTest class is implemented by several resource-related test classes. The ResourceTest class is tied to JUnit 3, such that all derived test class also have to stick to JUnit 3.

Due to the high amount of tests relying on the class (including session tests that use a specific test runner that currently also relies on JUnit 3), migration to JUnit 4 has to happen incrementally to avoid a huge RP with a high risk of errors. One impediment is the test class hierarchy given by JUnit 3. Precisely, ResourceTest contains a bunch of utility methods that could/should actually be placed in an independent utility class, so that using these utilities does not enforce the embedding of a test class into a specific type hierarchy. This is also the pattern used for assertions, which were provided via inheritance in JUnit 3 and were moved to dedicated assertion classes in JUnit 4. Functionality in ResourceTest that is stateful, as well as common setup/cleanup functionality, can be placed in test rules (JUnit 4) or extensions (JUnit 5).

I have already started with preparatory refactorings to remove JUnit-3-specific functionality from test classes, such as using fail for failing with an exception rather than throwing the exception by the test method.
I will do the following to incrementally migrate the ResourceTests:

  • Move all utility functionality from ResourceTest into a utility class
  • Move all stateful and setup/cleanup functionality from ResourceTest into test rules
  • Incrementally remove inheritance of all ResourceTest specializations and migrate them to JUnit 4
  • Replace the SessionTestSuite and all session tests with a JUnit-4-conforming implementation

Upcoming PRs will target these goals. In case you have objections to the procedure, please let me know.

One point I want to mention explicitly: one might argue for inheriting utility methods as a matter of convenience, but the current complexity to migrate the tests shows how unmaintainable it is to use inheritance for providing utilites, as it forces you to use a specific type hierarchy to use utilty functionality.

@HeikoKlare HeikoKlare added enhancement New feature or request test junit test related things labels Nov 30, 2023
@HeikoKlare HeikoKlare self-assigned this Nov 30, 2023
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Nov 30, 2023
…pse-platform#903

This changes moves all assert* utility methods defined in ResourceTest
to a dedicated ResourceTestUtil test class. It prepares for removing the
JUnit 3 test inheritances hierarchy to migrate to JUnit 4.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Nov 30, 2023
…-platform#903

This changes moves all create*/ensure* utility methods defined in
ResourceTest to the dedicated ResourceTestUtil test class. It renames
the ensureDoesNotExist* methods to remove* to avoid name clashes and
make the performed removal more explicit. It prepares for removing the
JUnit 3 test inheritances hierarchy to migrate to JUnit
4.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Nov 30, 2023
…-platform#903

This changes moves the getWorkspace() utility method defined in
ResourceTest to the dedicated ResourceTestUtil test class. It prepares
for removing the JUnit 3 test inheritances hierarchy to migrate to JUnit
4.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Nov 30, 2023
…form#903

This change moves the constants and related methods referring to
extensions of resources test plugin from the ResourceTest class to a
separate utility class. It prepares for removing the JUnit 3 inheritance
hierarchy of ResourceTest to migrate to JUnit 4.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Nov 30, 2023
…form#903

This change moves the constants and related methods referring to
extensions of resources test plugin from the ResourceTest class to a
separate utility class. It prepares for removing the JUnit 3 inheritance
hierarchy of ResourceTest to migrate to JUnit 4.

Contributes to
eclipse-platform#903
HeikoKlare added a commit that referenced this issue Dec 1, 2023
This change moves the constants and related methods referring to
extensions of resources test plugin from the ResourceTest class to a
separate utility class. It prepares for removing the JUnit 3 inheritance
hierarchy of ResourceTest to migrate to JUnit 4.

Contributes to
#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 1, 2023
…pse-platform#903

This changes moves all assert* utility methods defined in ResourceTest
to a dedicated ResourceTestUtil test class. It prepares for removing the
JUnit 3 test inheritances hierarchy to migrate to JUnit 4.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 1, 2023
…-platform#903

This changes moves all create*/ensure* utility methods defined in
ResourceTest to the dedicated ResourceTestUtil test class. It renames
the ensureDoesNotExist* methods to remove* to avoid name clashes and
make the performed removal more explicit. It prepares for removing the
JUnit 3 test inheritances hierarchy to migrate to JUnit
4.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 1, 2023
…-platform#903

This changes moves the getWorkspace() utility method defined in
ResourceTest to the dedicated ResourceTestUtil test class. It prepares
for removing the JUnit 3 test inheritances hierarchy to migrate to JUnit
4.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 4, 2023
…pse-platform#903

Replaces all calls to CoreTest.assertEquals() for comparing array
contents with matcher statements. This makes the assertions independent
from JUnit 3 and improves the provided error messages in case of a test
failure. The change also improves the other assertions in the touched
test classes.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 4, 2023
…pse-platform#903

Replaces all calls to CoreTest.assertEquals() for comparing array
contents with matcher statements. This makes the assertions independent
from JUnit 3 and improves the provided error messages in case of a test
failure. The change also improves the other assertions in the touched
test classes.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 4, 2023
…pse-platform#903

Replaces all calls to CoreTest.assertEquals() for comparing array
contents with matcher statements. This makes the assertions independent
from JUnit 3 and improves the provided error messages in case of a test
failure. The change also improves the other assertions in the touched
test classes.

Contributes to
eclipse-platform#903
HeikoKlare added a commit that referenced this issue Dec 4, 2023
Replaces all calls to CoreTest.assertEquals() for comparing array
contents with matcher statements. This makes the assertions independent
from JUnit 3 and improves the provided error messages in case of a test
failure. The change also improves the other assertions in the touched
test classes.

Contributes to
#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 4, 2023
Simplifies the NatureTest class as preparation to migrate from JUnit 3:
* Removes unnecessary try-catch blocks or replaces them with
assertThrows statements
* Replaces fail() operations called in other threads by passing
exception outside
* Makes test methods rethrow exception rather than calling fail()
* Improves testBug338055() by joining spawned job

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 4, 2023
…platform#903

* Removes unnecessary try-catch blocks or replaces them with
assertThrows statements
* Throw exceptions instead of calling fail()
* Remove unnecessary cleanup functionality

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 4, 2023
…-platform#903

The ResourceTest class provides several functions for defining and
creating a hierarchy of resources encoded into a string array. This
functionality is hard to understand as it uses a default factory method
in the ResourceTest class that may be called by a template method in
ResourceTest and may be overwritten in subclasses. In addition, the
functionality is not used very often.

This change streamlines the functionality for creating resource
hierarchies. It makes the creation explicit where it is required by
inlining the string definitions where possible or implementing the
hierarchy creation in the actual test class rather than relying on the
template method in the ResourceTest superclass. This makes the tests
more independent from their JUnit 3-specific type hierarchy.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 4, 2023
…-platform#903

The ResourceTest class provides several functions for defining and
creating a hierarchy of resources encoded into a string array. This
functionality is hard to understand as it uses a default factory method
in the ResourceTest class that may be called by a template method in
ResourceTest and may be overwritten in subclasses. In addition, the
functionality is not used very often.

This change streamlines the functionality for creating resource
hierarchies. It makes the creation explicit where it is required by
inlining the string definitions where possible or implementing the
hierarchy creation in the actual test class rather than relying on the
template method in the ResourceTest superclass. This makes the tests
more independent from their JUnit 3-specific type hierarchy.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 4, 2023
…lipse-platform#903

The method ResourceTest#setBuildOrder() has two consuming paths in the
inheritance hierarchy, one concrete test class and one abstract test
class that is lower in the type hierarchy. This change pushes down the
utility method to clean up the REsourceTest inheritance hierarchy.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Dec 4, 2023
…lipse-platform#903

The method ResourceTest#setBuildOrder() has two consuming paths in the
inheritance hierarchy, one concrete test class and one abstract test
class that is lower in the type hierarchy. This change pushes down the
utility method to clean up the REsourceTest inheritance hierarchy.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 15, 2024
…tform#903

Migrates the tests in org.eclipse.core.tests.internal.watson to JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 or AssertJ assertions
- Restructure the tests: replace misused inheritance with helper class,
replace polymorphic with imperative behavior specification, and
parameterize tests

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 15, 2024
Migrates the tests in org.eclipse.core.tests.interal.propertytester to
JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 assertions
- Parameterize tests

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 15, 2024
Migrates the tests in org.eclipse.core.tests.interal.propertytester to
JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 assertions
- Parameterize tests

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 15, 2024
…tform#903

Migrates the tests in org.eclipse.core.tests.internal.watson to JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 or AssertJ assertions
- Restructure the tests: replace misused inheritance with helper class,
replace polymorphic with imperative behavior specification, and
parameterize tests

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 18, 2024
Migrates the tests in org.eclipse.ant.tests.core to JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 test suites with JUnit platform suites
- Replace JUnit 4 assertions with JUnit 5 assertions

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 19, 2024
Migrates the tests in org.eclipse.ant.tests.core to JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 test suites with JUnit platform suites
- Replace JUnit 4 assertions with JUnit 5 assertions

Contributes to
eclipse-platform#903
HeikoKlare added a commit that referenced this issue Sep 19, 2024
Migrates the tests in org.eclipse.ant.tests.core to JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 test suites with JUnit platform suites
- Replace JUnit 4 assertions with JUnit 5 assertions

Contributes to
#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 19, 2024
Migrates the tests in org.eclipse.core.tests.internal.utils to JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 or AssertJ assertions

Contributes to
eclipse-platform#903
HeikoKlare added a commit that referenced this issue Sep 19, 2024
Migrates the tests in org.eclipse.core.tests.internal.utils to JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 or AssertJ assertions

Contributes to
#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 19, 2024
Migrates the tests in org.eclipse.core.tests.interal.propertytester to
JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 assertions
- Parameterize tests

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 20, 2024
Migrates the tests in org.eclipse.core.tests.interal.propertytester to
JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 assertions
- Parameterize tests

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 21, 2024
Migrates the tests in org.eclipse.core.tests.interal.propertytester to
JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 assertions
- Parameterize tests

Contributes to
eclipse-platform#903
akurtakov pushed a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 30, 2024
…tform#903

Migrates the tests in org.eclipse.core.tests.internal.watson to JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 or AssertJ assertions
- Restructure the tests: replace misused inheritance with helper class,
replace polymorphic with imperative behavior specification, and
parameterize tests

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Sep 30, 2024
…tform#903

Migrates the tests in org.eclipse.core.tests.internal.watson to JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 or AssertJ assertions
- Restructure the tests: replace misused inheritance with helper class,
replace polymorphic with imperative behavior specification, and
parameterize tests

Contributes to
eclipse-platform#903
HeikoKlare added a commit that referenced this issue Oct 1, 2024
Migrates the tests in org.eclipse.core.tests.internal.watson to JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 or AssertJ assertions
- Restructure the tests: replace misused inheritance with helper class,
replace polymorphic with imperative behavior specification, and
parameterize tests

Contributes to
#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Oct 1, 2024
Migrates the tests in org.eclipse.core.tests.interal.propertytester to
JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 assertions
- Parameterize tests

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Oct 1, 2024
Migrates the tests in org.eclipse.core.tests.interal.propertytester to
JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 assertions
- Parameterize tests

Contributes to
eclipse-platform#903
HeikoKlare added a commit that referenced this issue Oct 1, 2024
Migrates the tests in org.eclipse.core.tests.interal.propertytester to
JUnit 5.
- Exchange JUnit 4 test annotations
- Replace JUnit 4 assertions with JUnit 5 assertions
- Parameterize tests

Contributes to
#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Nov 3, 2024
Simplifies the tests in org.eclipse.core.tests.resources.content:
* Removes obsolete ContentTypeTest superclass for test classes, uses
existing utility functionality instead
* Removes obsolete numbering of assertions
* Replaces try/catch/fail with assertThrows or making test framework
handle the exception

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Nov 3, 2024
Migrates the tests in org.eclipse.core.tests.resources.content to JUnit
5 by replacing according JUnit annotations and migrating assertions.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Nov 3, 2024
Migrates the tests in org.eclipse.core.tests.resources.content to JUnit
5 by replacing according JUnit annotations and migrating assertions.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Nov 3, 2024
Migrates the tests in org.eclipse.core.tests.resources.content to JUnit
5 by replacing according JUnit annotations and migrating assertions.

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Nov 6, 2024
Simplifies the tests in org.eclipse.core.tests.resources.content:
* Removes obsolete ContentTypeTest superclass for test classes, uses
existing utility functionality instead
* Removes obsolete numbering of assertions
* Replaces try/catch/fail with assertThrows or making test framework
handle the exception

Contributes to
eclipse-platform#903
HeikoKlare added a commit to HeikoKlare/eclipse.platform that referenced this issue Nov 6, 2024
Migrates the tests in org.eclipse.core.tests.resources.content to JUnit
5 by replacing according JUnit annotations and migrating assertions.

Contributes to
eclipse-platform#903
HeikoKlare added a commit that referenced this issue Nov 7, 2024
Simplifies the tests in org.eclipse.core.tests.resources.content:
* Removes obsolete ContentTypeTest superclass for test classes, uses
existing utility functionality instead
* Removes obsolete numbering of assertions
* Replaces try/catch/fail with assertThrows or making test framework
handle the exception

Contributes to
#903
HeikoKlare added a commit that referenced this issue Nov 7, 2024
Migrates the tests in org.eclipse.core.tests.resources.content to JUnit
5 by replacing according JUnit annotations and migrating assertions.

Contributes to
#903
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request test junit test related things
Projects
None yet
Development

No branches or pull requests

2 participants