at:tutorial:appendix
Differences
This shows you the differences between two versions of the page.
Next revisionBoth sides next revision | |||
at:tutorial:appendix [2008/07/08 11:31] – added tvcutsem | at:tutorial:appendix [2008/07/08 11:46] – added tvcutsem | ||
---|---|---|---|
Line 5: | Line 5: | ||
===== Unit Testing Framework ===== | ===== Unit Testing Framework ===== | ||
- | The file '' | + | The file '' |
====== Creating a Unit Test ====== | ====== Creating a Unit Test ====== | ||
Line 25: | Line 25: | ||
</ | </ | ||
- | This will execute all '' | + | This will execute all '' |
- | Like in JUnit and SUnit, it is possible to define two methods named '' | + | Like in JUnit and SUnit, it is possible to define two methods named '' |
====== Assertions ====== | ====== Assertions ====== | ||
Line 57: | Line 57: | ||
<note warning> | <note warning> | ||
- | Be sure to invoke the above assertion methods | + | A common mistake is to invoke the above assertion methods as if they were lexically visible (e.g. invoking '' |
</ | </ | ||
====== Asynchronous Unit Tests ====== | ====== Asynchronous Unit Tests ====== | ||
- | When a method is prefixed with ' | + | Up to now, the unit testing framework assumed that all of your unit tests consisted of purely synchronous method invocations. When running the tests, all '' |
+ | |||
+ | To support unit test methods that need to perform asynchronous invocations (e.g. those performing concurrent or distributed unit tests), the unit testing framework introduces a new prefix: all methods that spawn asynchronous computation must be prefixed with '' | ||
+ | |||
+ | When a method is prefixed with '' | ||
+ | |||
+ | < | ||
+ | def testAsyncFutures() { | ||
+ | import / | ||
+ | def adder := object: { def inc(x) { x+1 } }; | ||
+ | def f := when: adder< | ||
+ | self.assertEquals(43, | ||
+ | }; | ||
+ | f | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | The unit test framework will invoke this method, receive a future '' | ||
+ | |||
+ | It is also possible to use '' | ||
====== Test Suites ====== | ====== Test Suites ====== |
at/tutorial/appendix.txt · Last modified: 2021/09/24 10:28 by elisag