Multiple unittest files to be executed by Maven [message #1805444] |
Mon, 15 April 2019 07:34  |
Eclipse User |
|
|
|
I have an Xtext project, say org.xtext.example.mydsl. I try to convert it to a headless one. In particular, I would like it to be built and tested based on Maven.
Given I want to maintain the unittests of sub-project org.xtext.example.mydsl.tests in the form of multiple files. For example, given I have the following two files
- MyDslParsingTest.xtend (Generated during workflow execution)
- MyDslWHATEVERTest.xtend (Manual copy paste of the file above)
When I run in the directory of the parent project, org.xtext.example.mydsl.parent
Then only the tests of the first file, MyDslParsingTest.xtend, are executed.
What do I have to do in order to let Maven also execute the tests of the manually crafted file, MyDslWHATEVERTest.xtend?
|
|
|
|
Re: Multiple unittest files to be executed by Maven [message #1805567 is a reply to message #1805520] |
Wed, 17 April 2019 10:00   |
Eclipse User |
|
|
|
At least, I solved the symptoms of my issue. However, I have to admit that I do not understand the solution. Here is the review:
The symptom was that only those unittests were executed by Maven which were part of the original (auto generated) file, e.g. MyDslParsingTest.xtend.
Unittests of other files, e.g. MyDslWHATEVERTest.xtend, were not considered by Maven at all. Eventually, I compared the two file types and discovered differences in the "setup" (I mean: imports and injections).
Unittests in this file are executed by Maven: MyDslParsingTest.xtend
import com.google.inject.Inject
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.extensions.InjectionExtension
import org.eclipse.xtext.testing.util.ParseHelper
import org.example.hellomaven.helloMaven.Model
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.^extension.ExtendWith
@ExtendWith(InjectionExtension)
@InjectWith(HelloMavenInjectorProvider)
class HelloMavenParsingTest {
@Inject ParseHelper<Model> parseHelper
@Test
...
Unittests in this file are NOT executed by Maven: MyDslWHATEVERTest.xtend
import com.google.inject.Inject
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.xbase.testing.CompilationTestHelper
import org.junit.Test
import org.junit.runner.RunWith
import static org.junit.Assert.*
@RunWith(typeof(XtextRunner))
@InjectWith(typeof(SismicInjectorProvider))
class HelloMavenWHATEVERTest {
@Inject extension CompilationTestHelper
@Test
...
The "setup" of the latter, I finally modified it to the following:
Unittests in this file ARE now executed by Maven: MyDslWHATEVERTest.xtend
import com.google.inject.Inject
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.extensions.InjectionExtension
import org.eclipse.xtext.xbase.testing.CompilationTestHelper
import org.eclipse.xtext.testing.XtextRunner
import org.junit.runner.RunWith
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.^extension.ExtendWith
@ExtendWith(InjectionExtension)
@InjectWith(SismicInjectorProvider)
class SismicGenerationTest implements completeScenarioWithFrancaReferences {
@Inject extension CompilationTestHelper
@Test
...
The thrilling thing for me was that in the Eclipse IDE, I could launch all tests from all files. Everything was working. However, Maven had a different perspective ...
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04525 seconds