Parameterized unit test [message #1726787] |
Wed, 16 March 2016 09:45  |
Eclipse User |
|
|
|
Hi,
Sorry if I ask a dummy question or if there is already an answer on another topic (I did search for it but didn't find anything), I'm a newbie with xtext.
I created a grammar for my language and I want to create an unit test suite to validate all the files in one folder. According to tutorial, I created a small test for one file like this :
package my.package.tests
import org.junit.runner.RunWith
import org.eclipse.xtext.junit4.XtextRunner
import org.eclipse.xtext.junit4.InjectWith
import com.google.inject.Inject
import org.eclipse.xtext.junit4.util.ParseHelper
import org.eclipse.xtext.junit4.validation.ValidationTestHelper
import org.junit.Test
import java.nio.file.Files
import my.package.parser.mylang.Procedure
import java.nio.file.Paths
@RunWith(typeof(XtextRunner))
@InjectWith(typeof (MyLangInjectorProvider))
class MyLangParsingTestFullFolder{
@Inject extension ParseHelper<Procedure> modelParserHelper
@Inject extension ValidationTestHelper
@Test
def testProcedureParser(){
val fileContent = new String(Files.readAllBytes(Paths.get("c:\\RunTests\\Files\\_TEST")))
var model=modelParserHelper.parse(fileContent)
model.assertNoErrors()
}
}
Now, instead of having one test for each file I would like to have a parameterized unit test, to get all the files from that folder and execute the test for each one. Is there a "ParameterizedXtextRunner" (I did find something like this, but it is deprecated) or something similar? Can anybody give me an example of such test?
Thank you
|
|
|
|
|
|
|
|
|
Re: Parameterized unit test [message #1792817 is a reply to message #1792815] |
Tue, 24 July 2018 07:08  |
Eclipse User |
|
|
|
Ok I actually just found the solution myself...
It turns out adding org.junit.runners.parameterized to the Import-Package section of MANIFEST.MF solves both the build and run problems. I'm not sure what the semantics of Import-Package is and why it happens to fix the problem, but it does. So there you go, for future encounters of that issue :)
Cheers
|
|
|
Powered by
FUDForum. Page generated in 0.05199 seconds