FB_SkipAssertionsWhenFinished Function Block
Extends TcUnit.FB_TestSuite
Contains tests that require multiple cycles: - A short test that finishes quickly - The assert statements all pass while the test is not finished - After the test is finished, the variables change so that the assert statements now fail, which shouldn't matter because the test is finished - A long test that finishes slowly - This test exists so that the entire test suite keeps running after the short test finishes
Variables
| Name | Type | Default | Description |
|---|---|---|---|
ShortTimer |
TON | (PT := T#200MS) |
|
LongTimer |
TON | (PT := T#1S) |
Methods
Test_AssertImmediatelyAfterFinished
Assertions called immediately after (and within the same cycle as) TEST_FINISHED should be ignored.
Implementation
TEST('Test_AssertImmediatelyAfterFinished');
TEST_FINISHED();
AssertTrue(FALSE, 'This failing assertion should be skipped because the test is finished');
Test_LongTest
Parameters
| Name | Type | Description |
|---|---|---|
Timer |
POINTER TO TON |
Implementation
TEST('Test_LongTest');
Timer^(IN := TRUE);
IF Timer^.Q THEN
TEST_FINISHED();
END_IF
Test_ShortTest
Parameters
| Name | Type | Description |
|---|---|---|
Timer |
POINTER TO TON |
Implementation
TEST('Test_ShortTest');
AssertFalse(Timer^.Q, 'This assertion will start to fail after the test is over, but it will be skipped at that point');
Timer^(IN := TRUE);
IF Timer^.Q THEN
TEST_FINISHED();
END_IF
Used by
Declaration source
(*
Contains tests that require multiple cycles:
- A short test that finishes quickly
- The assert statements all pass while the test is not finished
- After the test is finished, the variables change so that the assert statements now fail,
which shouldn't matter because the test is finished
- A long test that finishes slowly
- This test exists so that the entire test suite keeps running after the short test finishes
*)
FUNCTION_BLOCK FB_SkipAssertionsWhenFinished EXTENDS TcUnit.FB_TestSuite
VAR
ShortTimer : TON := (PT := T#200MS);
LongTimer : TON := (PT := T#1S);
END_VAR