Changes between Version 7 and Version 8 of Obsolete/Development/Code/TestingComponents


Ignore:
Timestamp:
Apr 24, 2012, 11:29:12 PM (14 years ago)
Author:
munoz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Obsolete/Development/Code/TestingComponents

    v7 v8  
    117117}}}
    118118
    119 === Testing the `Configure` method ===
     119=== Testing with real profiles (the `Configure` method) ===
    120120
    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:
     121Sometimes it's more convenient to have a mockup profile, and get that configuration. Here comes my advice:
    122122
    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:
     1231. 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:
    124124{{{
    125125#!sh
     
    130130"b" = 2;
    131131}}}
    132 1. This 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:
     1321. 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:
    133133{{{
    134134#!perl
     
    145145$comp->Configure($config);
    146146}}}
     1471. Or, if your tests can benefit from it, extract portions of it with `getTree()`:
     148{{{
     149#!perl
     150my $t = $config->getElement("/software/components/foo")->getTree();
     151$comp->a_lesser_method($t->{a_subtree});
     152}}}
    147153
    148154And test whatever you need to test. Simple, right?
     155
     156Always 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.
    149157
    150158== Running the tests ==