|
@@ -1,13 +1,13 @@
|
|
|
<img src="logo.png" align="right" />
|
|
|
<p>A unit testing Module based loosely on JUnit.</p>
|
|
|
-To define a test :<br>
|
|
|
+To define a test :<br/>
|
|
|
<ol>
|
|
|
<li> implement a sub-Type of TTest</li>
|
|
|
-<li> initialize the user states by creating a Method tagged with {before}</li>
|
|
|
-<li> clean-up after a test by creating a Method tagged with {after}.</li>
|
|
|
+<li> initialize the user states by creating a Method tagged with `{before}`</li>
|
|
|
+<li> clean-up after a test by creating a Method tagged with `{after}`.</li>
|
|
|
</ol>
|
|
|
Here is an example:
|
|
|
-<pre>
|
|
|
+```blitzmax
|
|
|
Type MyTest Extends TTest
|
|
|
|
|
|
Local value1:Int
|
|
@@ -19,24 +19,24 @@ Type MyTest Extends TTest
|
|
|
End Method
|
|
|
|
|
|
End Type
|
|
|
-</pre>
|
|
|
+```
|
|
|
For each test implement a @Method which interacts with the fixture. You tell MaxUnit that this is a test Method by
|
|
|
tagging it with {test}. The Method can otherwise be called anything you like. It should take no parameters and not
|
|
|
-return anything.<br>
|
|
|
+return anything.<br/>
|
|
|
Verify the expected results with assertions specified by calling @assertTrue with a boolean.
|
|
|
-<pre>
|
|
|
+```blitzmax
|
|
|
Method testAdd() { test }
|
|
|
Local result:Int = value1 + value2
|
|
|
assertTrue(result = 5)
|
|
|
End Method
|
|
|
-</pre>
|
|
|
+```
|
|
|
Finally, you can run the tests by creating an instance of the TTestSuite and calling its @run method.
|
|
|
-<pre>
|
|
|
+```blitzmax
|
|
|
New TTestSuite.run()
|
|
|
-</pre>
|
|
|
-The following code snippet is a complete example, including a failed test :<br>
|
|
|
+```
|
|
|
+The following code snippet is a complete example, including a failed test :<br/>
|
|
|
You can open the source <a href="example.bmx">here</a>.
|
|
|
-<pre>
|
|
|
+```blitzmax
|
|
|
SuperStrict
|
|
|
|
|
|
Import BRL.MaxUnit
|
|
@@ -69,9 +69,9 @@ Type MyTest Extends TTest
|
|
|
End Method
|
|
|
|
|
|
End Type
|
|
|
-</pre>
|
|
|
+```
|
|
|
The above program should produce the following output :
|
|
|
-<pre>
|
|
|
+```
|
|
|
[0] ..F
|
|
|
|
|
|
There was 1 failure:
|
|
@@ -84,4 +84,4 @@ Tests run: 3, Failures: 1, Errors: 0
|
|
|
Time: 0.0
|
|
|
|
|
|
Process complete
|
|
|
-</pre>
|
|
|
+```
|