Example: Test EOL scripts with EUnit

operation integers() {
  assertEquals(2, 1 + 1);
  assertNotEquals(10, 1 + 1);

operation floats() {
  // Floating-point math: 0.01 * 10 is not exactly equal to 0.1
  assertNotEquals(0.1, 0.01 * 10);

  // We need to define an error margin. We use ulps, as in Math.ulp(double).
  // Here we use a margin of 10 ulps around the expected value (0.1). 
  assertEquals(0.1, 0.01 * 10, 10);

operation strings() {
  // assertEquals also works with Strings
  assertEquals("A", "A");
  assertNotEquals("A", "B");

operation errors() {
  // assertError only passes if an exception is thrown when evaluating its expression

operation customAssertion() {

operation assertStringContainsFoo(s: String) {
  if (not s.contains("Foo")) {
    fail("String '" + s + "' did not contain Foo");
  <target name="run-tests">
    <epsilon.eunit src="tests.eunit"/>

Clone Epsilon's Git repository and then:

Once you have checked out/imported the code, to run the example you need to go through the following steps:

  1. register any .ecore metamodels in the org.eclipse.epsilon.eunit.examples.eol project
  2. right click the .launch file in the org.eclipse.epsilon.eunit.examples.eol project
  3. select Run as... and click the first item in the menu that pops up

What's this?

In this example we show the basic structure of an EUnit test, some useful assertions for the basic types and how to test for errors and define our own assertions.

What are .emf files?

.emf files are Ecore metamodels expressed using the Emfatic textual syntax.

More examples...

Epsilon Object Language
Epsilon Transformation Language
Epsilon Generation Language
Epsilon Validation Language
Epsilon Merging Language
Epsilon Flock
Epsilon Model Generation Language
Epsilon Pattern Language
Combining the Epsilon Languages

Even more examples...

More examples are available in the examples folder of the Git repository.