Changes between Version 7 and Version 8 of Obsolete/Development/Code/TestingComponents
- Timestamp:
- Apr 24, 2012, 11:29:12 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Obsolete/Development/Code/TestingComponents
v7 v8 117 117 }}} 118 118 119 === Testing the `Configure` method===119 === Testing with real profiles (the `Configure` method) === 120 120 121 This method should have almost no logic. But it still deserves some testing. It must receive a valid `EDG::CCM::Configuration` object from a profile. And handling this is done by `Test::Quattor`. This is how we do it:121 Sometimes it's more convenient to have a mockup profile, and get that configuration. Here comes my advice: 122 122 123 1. We have a set of test profiles. They are minimalistic,and have no dependencies on any "standard" templates. Just assign a few values to fill in your component structure. For instance:123 1. Have a set of test profiles. They should be tiny and have no dependencies on any "standard" templates. Just assign a few values to fill in your component structure. For instance: 124 124 {{{ 125 125 #!sh … … 130 130 "b" = 2; 131 131 }}} 132 1. Th is profile must be compiled, and a cache must be created for it. The`Test::Quattor` comes in hand here: If you pass any arguments to it, it will compile them and prepare the correct cache:132 1. These profiles must be compiled and a cache created for it. `Test::Quattor` comes in hand here: If you pass any arguments to it, it will compile them and prepare the correct cache: 133 133 {{{ 134 134 #!perl … … 145 145 $comp->Configure($config); 146 146 }}} 147 1. Or, if your tests can benefit from it, extract portions of it with `getTree()`: 148 {{{ 149 #!perl 150 my $t = $config->getElement("/software/components/foo")->getTree(); 151 $comp->a_lesser_method($t->{a_subtree}); 152 }}} 147 153 148 154 And test whatever you need to test. Simple, right? 155 156 Always remember that the `Configure` method should be terribly simple, with almost no logic. The bulk of your tests will focus in the methods of your component that do the real work. 149 157 150 158 == Running the tests ==