How to Start Using Xpect

Let's assume you hava an Xtext-Language you want to test which uses the file extension *.dmodel.
If you don't have such a language, get one in Eclipse via File -> New -> Example -> Xtext Examples -> Xtext Domain Model.

If you don't have the language installed, launch a runtime workbench where it is installed.

Create a new Plug-in Project and add org.xpect.xtext.lib,
your languages runtime-project (the one with the grammar inside) and your ui-project to the dependencies.

If you do a right mouse click onto the file and choose "open with" in the menu, there are three editors available:
(1) An Xpect+Xtext editor with highlighting, content assist, etc. for both your language and the Xpect syntax.
(2) An Xpect editor with support for the Xpect syntax.
(3) The editor for your language that you build.

Running the Java class as JUnit test executes the test cases specified in the mytest.dmodel.xt file.

If a test fails, double-clicking on it in the JUnit view opens a comparison editor which compares
the test's expectation with the actual test result. This eases understanding why a test fails dramatically.

In the context menu of a test in the JUnit view, you can select "go to XPECT" to open and select test case in the DSL-File.

Find further examples for the Domainmodel Language here.
For a more extensive introduction, see my blog