FB_MultipleAssertWithSameParametersInDifferentCyclesButWithDifferentTests  Function Block

Extends TcUnit.FB_TestSuite

This test-suite runs several asserts with the same parameters (same expected, actual, message), calling the asserts in different cycles and using different tests. On top of this, we will call new asserts (though with same parameters) in later cycles. The reason we want the framework to support this is that theoretically the user could want to do an assert with the same message, in different tests, with the same data values for both expected and actual, although the data that the user does the assert on might be from different data sets.


Variables

Name Type Default Description
TimerAgain TON (PT := T#1S) Timer to call "AssertSeveralTimesAgain"
TimerAgainAgain TON (PT := T#5S) Timer to call "AssertSeveralTimesAgainAgain"
CalledAll BOOL Indication of whether we've called all tests

Methods

Assert_SeveralTimes PRIVATE
Implementation
TEST('Assert_SeveralTimes');

AssertEquals_DWORD(Expected := a,
                   Actual := b,
                   Message := 'Values differ');

AssertEquals_DWORD(Expected := c,
                   Actual := d,
                   Message := 'Values differ');

AssertEquals_DWORD(Expected := e,
                   Actual := f,
                   Message := 'Values differ');

IF CalledAll THEN
    TEST_FINISHED();
END_IF
Assert_SeveralTimesAgain PRIVATE
Implementation
TEST('Assert_SeveralTimesAgain');

AssertEquals_DWORD(Expected := a,
                   Actual := b,
                   Message := 'Values differ');

AssertEquals_DWORD(Expected := c,
                   Actual := d,
                   Message := 'Values differ');

AssertEquals_DWORD(Expected := e,
                   Actual := f,
                   Message := 'Values differ');

IF CalledAll THEN
    TEST_FINISHED();
END_IF
Assert_SeveralTimesAgainAgain PRIVATE
Implementation
TEST('Assert_SeveralTimesAgainAgain');

AssertEquals_DWORD(Expected := a,
                   Actual := b,
                   Message := 'Values differ');

AssertEquals_DWORD(Expected := c,
                   Actual := d,
                   Message := 'Values differ');

AssertEquals_DWORD(Expected := e,
                   Actual := f,
                   Message := 'Values differ');

IF CalledAll THEN
    TEST_FINISHED();
END_IF

Used by

Declaration source
(*
    This test-suite runs several asserts with the same parameters (same expected, actual, message), calling the asserts
    in different cycles and using different tests.
    On top of this, we will call new asserts (though with same parameters) in later cycles.
    The reason we want the framework to support this is that theoretically the user could want to do an assert with the
    same message, in different tests, with the same data values for both expected and actual, although the data that the
    user does the assert on might be from different data sets.
*)
FUNCTION_BLOCK FB_MultipleAssertWithSameParametersInDifferentCyclesButWithDifferentTests EXTENDS TcUnit.FB_TestSuite
VAR
    TimerAgain : TON := (PT := T#1S); // Timer to call "AssertSeveralTimesAgain"
    TimerAgainAgain : TON := (PT := T#5S); // Timer to call "AssertSeveralTimesAgainAgain"
    CalledAll : BOOL; // Indication of whether we've called all tests
END_VAR