-
Notifications
You must be signed in to change notification settings - Fork 330
Replace JUnit 5 with JUnit 6 #3560
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a08bb07
Depend on JUnit 6 instead of JUnit 5
trancexpress 3414c39
Rename org.eclipse.xtext.junit5.tests to org.eclipse.xtext.junit6.tests
trancexpress 866535a
Renamed org.eclipse.xtext.testing.junit5.tests to org.eclipse.xtext.t…
trancexpress 2212980
Moved junit5 launches
trancexpress fc7feca
Replaced JUnit 5 mentions with JUnit 6
trancexpress e3c3674
Renamed mavenTychoJUnit5 to mavenTychoJUnit6
trancexpress a41f0b0
Replaced JUNIT_5 with JUNIT_6
trancexpress d532372
Updated JUnit versions to 6+ in targets
trancexpress 84f8e29
Updated more JUnit 5 locations
trancexpress File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -806,7 +806,7 @@ <h3 id="encoding-of-an-xtextresource">Encoding of an XtextResource</h3> | |
|
|
||
| <h2 id="testing">Unit Testing</h2> | ||
|
|
||
| <p>Automated tests are crucial for the maintainability and the quality of a software product. That is why it is strongly recommended to write unit tests for your language, too. The Xtext project wizard creates test projects for that purpose, which simplify the setup procedure for the basic language implementation as well as platform-specific integrations. It supports an option to either create your tests for JUnit 4 or JUnit 5. Depending on your choice your test layout will vary in some details.</p> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this needs to be fixed in (https://github.com/eclipse-xtext/xtext-website) pr against main
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| <p>Automated tests are crucial for the maintainability and the quality of a software product. That is why it is strongly recommended to write unit tests for your language, too. The Xtext project wizard creates test projects for that purpose, which simplify the setup procedure for the basic language implementation as well as platform-specific integrations. It supports an option to either create your tests for JUnit 4 or JUnit 6. Depending on your choice your test layout will vary in some details.</p> | ||
|
|
||
| <h3 id="creating-a-simple-test-class">Creating a Simple Test Class</h3> | ||
|
|
||
|
|
@@ -830,7 +830,7 @@ <h3 id="creating-a-simple-test-class">Creating a Simple Test Class</h3> | |
|
|
||
| <p>This configuration will make sure that you can use dependency injection in your test class, and that the global EMF registries are properly populated before and cleaned up after each test.</p> | ||
|
|
||
| <p>A test class for JUnit 5 looks quite similar. Instead of runners JUnit 5 has a notion of <a href="https://junit.org/junit5/docs/current/user-guide/#extensions">Extensions</a>. While there can only be one runner per test class for JUnit 4 there could be multiple extensions for JUnit 5. The replacement for the XtextRunner is the new <a href="https://github.com/eclipse-xtext/xtext/blob/main/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/extensions/InjectionExtension.java">InjectionExtension</a>. Still needed is the language specific <a href="https://github.com/eclipse-xtext/xtext/blob/main/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/IInjectorProvider.java">IInjectorProvider</a>. Instead of <code>org.junit.Test</code> you have to annotate your cases with <a href="https://github.com/junit-team/junit5/blob/master/junit-jupiter-api/src/main/java/org/junit/jupiter/api/Test.java">org.junit.jupiter.api.Test</a> and import the methods from <a href="https://github.com/junit-team/junit5/blob/master/junit-jupiter-api/src/main/java/org/junit/jupiter/api/Assertions.java">org.junit.jupiter.api.Assertions</a>. A simple test class for JUnit 5 will then look like this:</p> | ||
| <p>A test class for JUnit 6 looks quite similar. Instead of runners JUnit 6 has a notion of <a href="https://junit.org/junit5/docs/current/user-guide/#extensions">Extensions</a>. While there can only be one runner per test class for JUnit 4 there could be multiple extensions for JUnit 6. The replacement for the XtextRunner is the new <a href="https://github.com/eclipse-xtext/xtext/blob/main/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/extensions/InjectionExtension.java">InjectionExtension</a>. Still needed is the language specific <a href="https://github.com/eclipse-xtext/xtext/blob/main/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/IInjectorProvider.java">IInjectorProvider</a>. Instead of <code>org.junit.Test</code> you have to annotate your cases with <a href="https://github.com/junit-team/junit5/blob/master/junit-jupiter-api/src/main/java/org/junit/jupiter/api/Test.java">org.junit.jupiter.api.Test</a> and import the methods from <a href="https://github.com/junit-team/junit5/blob/master/junit-jupiter-api/src/main/java/org/junit/jupiter/api/Assertions.java">org.junit.jupiter.api.Assertions</a>. A simple test class for JUnit 6 will then look like this:</p> | ||
|
|
||
| <pre><code class="language-xtend">import org.eclipse.xtext.testing.InjectWith | ||
| import org.eclipse.xtext.testing.extensions.InjectionExtension | ||
|
|
@@ -903,7 +903,7 @@ <h3 id="testing-multiple-languages">Testing Multiple Languages</h3> | |
| } | ||
|
|
||
| // @RunWith(XtextRunner.class) // JUnit 4 | ||
| @ExtendWith(InjectionExtension.class) // JUnit 5 | ||
| @ExtendWith(InjectionExtension.class) // JUnit 6 | ||
| @InjectWith(MyLanguageWithDependenciesInjectorProvider.class) | ||
| public class YourTest { | ||
| ... | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.