Implementing tests for your DSL
Xtext highly fosters using unit tests, and this is reflected by the fact that, by default, the MWE2 workflow generates specific plug-in projects for testing your DSL. In fact, usually tests should reside in a separate project, since they should not be deployed as part of your DSL implementation. Xtext generates two test projects. One that ends with the .tests
suffix, for tests that do not depend on the UI, and one that ends with the .ui.tests
suffix, for tests that depend on the UI. For our Entities DSL, these two projects are org.example.entities.tests
and org.example.entities.ui.tests
. The test plug-in projects have the needed dependencies on the required Xtext utility bundles for testing.
We will use Xtend to write JUnit tests; thanks to all its features, tests will be easier to write and easier to read.
In the src-gen
directory of the test projects, you will find the injector providers for headless and UI tests respectively. You can use these providers...