Converting Xtext DSL tests to Junit5 [message #1848193] |
Wed, 24 November 2021 10:41  |
Eclipse User |
|
|
|
We are converting the Junit tests of our Xtext based DSL from Junit4 to JUnit5.
The tests in this test suite is extending the Xtext testing class
org.eclipse.xtext.testing.AbstractLanguageServerTest
It was straight forward to get the test suites to run correctly using JUnit5 within Eclipse (2020-06), i.e. to run it with "Run as JUnit Test".
However, when running the test suite in Maven it does not work. Have tried to follow the advice given in different internet posts, but don't get it right anyway. For example:
wiki.eclipse.org/Tycho/How_Tos/JUnit5
And
blogs.itemis.com/en/xtext-2.14-adds-support-for-junit-5
The error we get looks like this:
runTest: 212->AbstractCbbLspTest.testValidation:139->AbstractLanguageServerTest.initializeContext:1132->AbstractLanguageServerTest.initialize:340->AbstractLanguageServerTest.initialize:353->AbstractLanguageServerTest.lambda$initialize$1:348 » NullPointer
Running it in the debugger indicates that there is some problem with the execution of the @Before / @BeforeEach functions. The NullPointer above is a result of that the AbstractLanguageServerTest.setup() function isn't executed before the test case starts.
Also, when running in the debugger, I noticed that the class files of the org.junit.jupiter.engine package used when running with Maven does not seem to match the class files of the org.junit.jupiter.engine package that is used in Eclipse (version 5.6.0).
Our environment:
Eclipse 2020-06
Maven version 3.8.2
Maven compiler plugin version 3.8.1
Maven surefire plugin version 2.22.2
Junit 5 version 5.6.0
Java 11.0.1-1 (but we target Java 8 in our builds)
Tycho version 2.5.0
Xtext version 2.22.0
mwe2-launch-version 2.11.3
Due to a dependency that we don't control, we can't easily use versions later than Xtext 2.22.0 as we are bound to use Eclipse 2020-06 main release.
Any hints pointing me in the right direction are most welcome.
Best regards
Lars Gelin
-------------------------
Our Tycho configuration from the pom.xml of our Xtext Junit test suite:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>false</extensions>
<configuration>
<useUIHarness>false</useUIHarness>
<useUIThread>false</useUIThread>
<includes>
<include>**/*Test.java</include>
</includes>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<runOrder>alphabetical</runOrder>
<testRuntime>default</testRuntime>
<argLine>-ea</argLine>
</configuration>
</plugin>
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04501 seconds