Click here to Skip to main content
15,354,574 members
Articles / Desktop Programming / WPF
Posted 29 Jul 2020

Tagged as


10 bookmarked

Generic Testing Framework

Rate me:
Please Sign up or sign in to vote.
4.33/5 (6 votes)
30 Jul 2020CPOL1 min read
Generic framework to “programming” of any test cases in dynamic way
In this post, you will see a very generic framework to “programming” test cases in dynamic way which enables execution of “testing bricks” in a defined order.


This tool is a very generic framework to “programming” of any test cases in dynamic way, a dynamic “final state machine” that enables the execution of any “testing bricks” in a defined order.

Each "brick" is largely configurable in its parameters, the output of one "brick" can be redirected to the input of any other "brick". You can reference the output of the previous "bricks" by selecting the number of it in the combobox of the column "InputRow".

The order of the "bricks" can be changed easily by adding / deleting:

Adding a new Testing Step

After creating a test case, you can save it in a *.ETF file in order to use this pre-defined test case later:

Loading Test File

After running the test, a message box appears with result, the protocol file will be written in "%appdata%":

Test OK

29.07.2020 15:28:34: Creating Test Brick: OneStep ...
29.07.2020 15:28:34: Creating Test Brick: FindRegExp ...
29.07.2020 15:28:34: Creating Test Brick: AssertEqual ...
29.07.2020 15:34:17: STEP 1
29.07.2020 15:34:20: STEP 2
29.07.2020 15:34:20: Search for OK
29.07.2020 15:34:20: Found 1 times
29.07.2020 15:34:20: STEP 3
29.07.2020 15:34:20: EQ
29.07.2020 15:35:38: **** Test OK! ****


The interesting point is, how to change dynamically WPF GUI (code behind) by adding or deleting rows:

Changing XAML

This Grid is the object that we need to adjust. First we clear the "old" Grid and add all columns and rows:

private void CreateDataGrid()
 // Clear grid

 // Create Columns
 int nCol = 0;
 int nRow = 0;
 RowDefinition gridRow = new RowDefinition();
 gridRow.Height = new GridLength(25);

Also interesting is the possibility, to create a derived class from base instance:

Class Diagram

The TestBrickFactory "builds" a special "brick" from basic TestClass by knowing its name (Activator:

public static TestClass CreateTestBrick(TestClass oBase, string sName)
    Logger.Instance.Write("Creating Test Brick: " + sName + "...");
    string sBrickName = "TestingFramework.Model." + sName;

    var oType = Type.GetType(sBrickName);
    TestClass oClass = null;

    if (oType != null)
        oClass = (TestClass)Activator.CreateInstance(oType, oBase);

    return oClass;

Using the Code

It is very easy (thanks to reflection) to add the new testing "blocks!: this requires the creation of a new class that is derived from an abstract TestClass and the overwriting of a single virtual method ExecuteTestStep():

class OneStep : TestClass
    public OneStep(TestClass oBase) : base(oBase)
        TestBrick = "OneStep";

    public override string ExecuteTestStep()
       // Do Smth!


  • 29th July, 2020: Published (Vers. 1.0.1)
  • 30th July, 2020: Added Chapter "Implementation"
  • 10th August, 2020: Small update version 1.0.2


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Leo Chapiro
Software Developer
Germany Germany

I'm a software developer living in Germany with my family (wife & 2 sons).
My hobbies: sport, traveling, books (former reading, now hearing).
Welcome to my homepage:

Comments and Discussions

Questionit looks interesting Pin
Garth J Lancaster29-Jul-20 20:52
professionalGarth J Lancaster29-Jul-20 20:52 
AnswerRe: it looks interesting Pin
Leo Chapiro30-Jul-20 1:25
professionalLeo Chapiro30-Jul-20 1:25 
Hi Garth,

Thank you very much for your review / question!

>where is InputFromOutput defined/derived/injected/conjured ?

This is a very important point / feature of the tool: before the next testing step will be executed there is a method "MoveOutputToInput" that copies the output of a current step into the next step(s) if the reference (Column "Input Row") points to it!

This is a kind of "relative reference" like in an excel table - you can select the step which output you want to use in the current step.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.