FB_MultipleAssertWithSameParametersInDifferentCyclesAndInSameTest  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 the same test. 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, using the same test with the same data values for both expected and actual, and splitting the asserts on different cycles.


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');

TimerAgain(IN := TRUE);
IF TimerAgain.Q THEN
    TimerAgainAgain(IN := TRUE);
    AssertEquals_DWORD(Expected := g,
                       Actual := h,
                       Message := 'Values differ');
    AssertEquals_DWORD(Expected := i,
                       Actual := j,
                       Message := 'Values differ');
    AssertEquals_DWORD(Expected := k,
                       Actual := l,
                       Message := 'Values differ');
END_IF

IF TimerAgainAgain.Q THEN
    AssertEquals_DWORD(Expected := m,
                       Actual := n,
                       Message := 'Values differ');
    AssertEquals_DWORD(Expected := o,
                       Actual := p,
                       Message := 'Values differ');
    AssertEquals_DWORD(Expected := q,
                       Actual := rr,
                       Message := 'Values differ');
    CalledAll := TRUE;
    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 the same test.
    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, using the same test with the same data values for both expected and actual, and splitting the asserts
    on different cycles.
*)
FUNCTION_BLOCK FB_MultipleAssertWithSameParametersInDifferentCyclesAndInSameTest 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