Test framework guide

  1. You will need an EMF-IncQuery project, which contains an .eiq Query Definition file. Here you can find a working example project: https://github.com/ujhelyiz/EMF-IncQuery-Examples/tree/master/school/school.incquery
    You can create an own EMF-IncQuery project here: File | New | Project | EMF-IncQuery | EMF-IncQuery Project.
  1. You will need a plug-in project (!) which contains an instance model. If this project not a plug-in project, the jUnit Plug-in can’t load the instance model, so the test cases will not run.

    In this example https://github.com/ujhelyiz/EMF-IncQuery-Examples/tree/master/school/school.instancemodel you can find two school instance models with a school, years, classes, students, teachers, and courses.
    If you create a new plug-in project, you don’t need Activator (on the second wizard page, uncheck the „Generate an activator, a Java class that controls the plug-in’s life cycle”).

  1. The test project is an other plug-in project. For an example test project with the correct settings and a representative set of test definitions, see: https://github.com/ujhelyiz/EMF-IncQuery-Examples/tree/master/school/school.tests

    This project contains:

  • school.tests/src/school/tests

The basic and model manipulation test cases in .xtend file

An example model manipulation test, where change the School "Budapest University of Technology and Economics" name to "BME":

@Test
def changeSchoolName(){
val sns = snapshot
val pm = queryInputEIQ
pm.assertMatchResults(sns)
// MODEL MODIFICATION HERE
// change the School "Budapest University of Technology and Economics" name to "BME"
val matcher = pm.initializeMatcherFromModel(sns.EMFRootForSnapshot, "school.schools")
val s = matcher.oneArbitraryMatch.get("Sch") as School
Assert::assertNotNull(s)
if (s!=null) {
if(s.name == "Budapest University of Technology and Economics"){
s.setName("BME")
}
val newSns = sns.eResource.resourceSet.loadExpectedResultsFromUri("school.tests/model/tests_changeSchoolName.eiqsnapshot")
pm.assertMatchResults(newSns)
}
}

  • school.tests/model

Snapshot files

You can create an .eiqsnapshot file in Query Explorer: right click on a pattern result or the root of the patterns - Save EMF-IncQuery snapshot. Important: this file contains relative path to the instance model, so if you move this file to another folder, you need to check the path.

  • school.tests/SchoolTests.launch

JUnit run configurations. You can run the tests: right click  - run as - SchoolTests