|Converting Xtext DSL tests to Junit5 [message #1848193]
||Wed, 24 November 2021 15:41
| Lars Gelin
Registered: November 2012
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
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:
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).
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
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.
Our Tycho configuration from the pom.xml of our Xtext Junit test suite:
Powered by FUDForum
. Page generated in 0.01781 seconds