From e3d1c35ca36df2475fb10dab95659971bc6fa1e9 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 23 Aug 2007 19:13:28 +0200 Subject: [PATCH] documentation of my internal testcase runner --- tests/50components.tests | 49 +++++++++++++++++++++++++++++++++------- wiki/index.html | 45 +++++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 9 deletions(-) diff --git a/tests/50components.tests b/tests/50components.tests index 033aaf2d5..20bb036f1 100644 --- a/tests/50components.tests +++ b/tests/50components.tests @@ -1,16 +1,15 @@ +TESTING "Component Test Suite: ALL" ./test-components + -TESTING "Component Test Suite" ./test-components -TEST "Fac test" Factory_test < out: wrapping cmdline: @@ -37,11 +36,45 @@ out: 4|€| out: -->oo _O()O_ ä + € out: wrapping cmdline:... out: --> -out: Standard Cmdlineformat: one two +out: Standard Cmdlineformat:one two END -TEST "Parseoption" TestOption_test < Testgroup=ALL +out: --> Test-ID =--missing-- +out: --> remaining= +out: Testing invocation with cmdline: --help... +out: --> Testgroup=ALL +out: --> Test-ID =--missing-- +out: --> remaining= +out: Testing invocation with cmdline: --group TestGroupID... +out: --> Testgroup=TestGroupID +out: --> Test-ID =--missing-- +out: --> remaining= +out: Testing invocation with cmdline: SingleTestID... +out: --> Testgroup=ALL +out: --> Test-ID =SingleTestID +out: --> remaining=SingleTestID +out: Testing invocation with cmdline: SingleTestID --group TestGroupID... +out: --> Testgroup=TestGroupID +out: --> Test-ID =SingleTestID +out: --> remaining=SingleTestID +out: Testing invocation with cmdline: --group TestGroupID SingleTestID ... +out: --> Testgroup=TestGroupID +out: --> Test-ID =SingleTestID +out: --> remaining=SingleTestID +out: Testing invocation with cmdline: --group TestGroupID SingleTestID spam eggs... +out: --> Testgroup=TestGroupID +out: --> Test-ID =SingleTestID +out: --> remaining=SingleTestID spam eggs +out: Testing invocation with cmdline: SingleTestID spam --group TestGroupID --eggs... +out: --> Testgroup=TestGroupID +out: --> Test-ID =SingleTestID +out: --> remaining=SingleTestID spam --eggs END + +TEST "Factory_test" Factory_test < -
+
For running the automatic Tests, we use Cehteh's simple [[test.sh|TestSh]].
 
 This page is a proposal (by Ichthyo) how the various tests could be organized.
@@ -3564,6 +3564,49 @@ This page is a proposal (by Ichthyo) how the various tests could be organized.
 * the Testsuite executable provides some command line magic to select individual tests.
 * Top-level Testsuites or ''~Test-Collections'' for [[test.sh|TestSh]] contain calls to the different (sub)-Suites, together with the expected results/output
 
+!internal Testsuite runner
+The class {{{test::Suite}}} (common/test/suite.hpp) helps building an executable which will run all //registered// test case objects, or some group of such testcases. Each test case implements a simple interface and thus provides a {{{run (args)}}} function, moreover, it registers itself immediately alongside with his definition; this works by the usual trick of defining a static class object and calling some registration function from the constructor of this static var. See the following __hello-world-Example__:
+{{{
+#include <iostream>
+#include "common/test/run.hpp"
+    
+    class HelloWorld_test : public Test
+      {
+        virtual void run(Arg arg) 
+          {
+            greeting();
+          } 
+        
+        void greeting() 
+          { 
+            std::cout << "This is how the world ends...\n"; 
+          }
+      };
+
+    /** Register this test class to be invoked in some test groups (suites) */
+    LAUNCHER (HelloWorld_test, "unit function common");    
+}}}
+Notes:
+* type Arg is {{{typedef std::vector<string> & Arg;}}}
+* this vector may be {{{size()==0}}}, which means no comandline args available.
+* otherwise arg[0] is always the ID (normally the classname) of the test
+* the following args may contain further arguments passed from system commandline.
+* the test can/should produce output that can be checked with Cehteh's [[./test.sh|TestSh]].
+* the macro "LAUNCHER" expands to {{{Launch<HelloWorld_test> run_HelloWorld_test("HelloWorld_test","unit function common");}}}
+* note the second parameter to the macro (or the Laucher-ctor) is a space-delimited list of group names
+* thus any test can declare itself as belonging to some groups, and we can create a {{{test::Suite}}} for each group if we want.
+
+!!!invoking the testrunner
+The class {{{test::TestOption}}} predefines a boost-commandlineparser to support the following optons:
+
+|>|!{{{./test-components --group <groupID> [testID [arguments...]]}}}|
+|{{{--help}}}| options summary|
+|{{{--group|-g <groupID>}}}| build a Testsuite out of all tests from this group. If missing, ALL tests will be included |
+|{{{[testID]}}}| (optional) one single testcase. If missing, all testcases of the group will be invoked |
+|{{{--describe}}}| print all registered tests to stdout in a format suited for use with test.sh |
+Further commandline arguments are deliverd to a single testcase only if you specify a {{{testID}}}. Otherwise, all commandline arguments remaining after options parsing will be discarded and all tests of the suite will be run with an commandline vector of size()==0
+
+
 !conventions for the Buildsystem
 to help with automating the build, ichthyo would appreciate to have the following conventions.
 * in the {{{tests}}} directory are