11/5/2010 1:31:32 PM
 Ludovic Dubois Administrator Posts: 159
|
In this videos (10:16 and 19:42), you will learn how to refactor your tests:
- Simple context of a test
Only one method to write code to run before and after the actual test. testcontext { // Add code to run before the test run here runtest; // Execute any test // Add code to run after the test run here }
- Separate tests based on different context needs
Typically, you should have several testclass for testing one business class: one for testing constructors, one for testing static declarations and one for testing non-static declarations. This one needs an instance to be created, thus it can be done in the testcontext.
- Stronger tests, better goal representation
Ensure that tests really test what you think with assertions before runtest. More, this will show you what the context is before runnning the tested statement and what it is after, thus what this tested statement changes!
- Repeat tests for different contexts
Rerun tests with almost any code testcontext { // Add code to set the first context runtest; // Execute any test within this first context // Add code to set the second context runtest; // Execute any test within this second context // Add code to run after the test run twice here }
- Add contexts to testclass and testing assembly too
Add context for any test, any testing class and/or the whole testing assembly testcontext { test { // Add code to set the context of any test runtest; // Execute any test // Add code to run after the test run here } testclass { // Add code to set the context of this testclass runtest; // Execute all tests of this testclass // Add code to run after all the test of this testclass run here } testassembly { // Add code to set the context of all the testclass of this assembly runtest; // Execute all tests of this assembly // Add code to run after all the tests of all the testclasses run here } }
Are you sure your tests test correctly what you think they test ? 
Access source code from our svn server at https://www.prettyobjects.com:7567/svn/public/TSharp/Samples/Products/?p=20
<em>edited by Ludovic Dubois on 05/11/2010</em>
|
|
|
0
• permalink
|