+ # Error occured during test-suite compilation.
+ var failure: nullable String = null
+end
+
+# A test case is a unit test considering only a `MMethodDef`.
+class TestCase
+
+ # Test suite wich `self` belongs to.
+ var test_suite: TestSuite
+
+ # Test method to be compiled and tested.
+ var test_method: MMethodDef
+
+ # `ToolContext` to use to display messages and find `nitg` bin.
+ var toolcontext: ToolContext
+
+ # `MMethodDef` to call before the test case.
+ var before_test: nullable MMethodDef = null
+
+ # `MMethodDef` to call after the test case.
+ var after_test: nullable MMethodDef = null
+
+ # Generate the test unit for `self` in `file`.
+ fun write_to_nit(file: Template) do
+ var name = test_method.name
+ file.addn "if name == \"{name}\" then"
+ if test_method.mproperty.is_toplevel then
+ file.addn "\t{name}"
+ else
+ file.addn "\tvar subject = new {test_method.mclassdef.name}.nitunit"
+ if before_test != null then file.addn "\tsubject.{before_test.name}"
+ file.addn "\tsubject.{name}"
+ if after_test != null then file.addn "\tsubject.{after_test.name}"
+ end
+ file.addn "end"
+ end
+