The dos and don'ts when testing
You need a test suite in order to execute →unit tests. The test suite in Excel format makes it simpler to modify the test suite. See "Structure of the Excel test suite, modifying the worksheets" for details.
Examples for test cases are provided under:
Page:(en) Example 2: Test case for counter with global/external variable
Page:(en) Example 3: Test case for addition with local variable, different test mode and stimuli
Page:(en) Example 4: Test case for myTon with simulated cycle time and unspecified test sequences
Page:(en) Modifying the Excel test suite, creating the test suite required for test execution
Page:(V3.10.0-de) Beispiel 2: Testfall für Counter mit globaler/externer Variablen
Page:(V3.10.0-de) Excel-Testsuite bearbeiten, Testsuite für Testausführung erzeugen
Page:(V3.10.0-en) Example 2: Test case for counter with global/external variable
Page:(V3.10.0-en) Example 3: Test case for addition with local variable, different test mode and stimuli
Page:(V3.10.0-en) Example 4: Test case for myTon with simulated cycle time and unspecified test sequences
Page:(V3.10.0-en) Modifying the Excel test suite, creating the test suite required for test execution
See "Restrictions when using the test frameworks" for a collection of all known restrictions regarding the test framework.
If you are using a division within a POU under test (e.g. the statement X := Y / (A-B) within an ST-code), create an additional test sequence within the test case. Within this test sequence, specify test data leading to a division by zero. If you execute an SiL-test with coverage but without this test sequence, there are branches which will not be covered.
When creating/opening a test project in a variant of logi.CAD 3 that is providing the test framework and when subsequently executing the tests, so-called internal meta files and other test files are automatically created. Usually, these files are not relevant. As a consequence and by default, these files are not displayed within the test project. If you create the test project within a GitHub repo, these files are listed within the appropriate Git commit. logi.cals recommends listing the following files/folders within the file .gitignore in order to exclude them from tracing by Git:
Name
Meaning
file red.xml
internal file which is automatically created when creating/opening the project
folder libspecs
folder with internal files which are automatically created when creating/opening the project
.settings\testbed_SiL\testbed_SiL.rule or .settings\testbed_PiL\testbed_PiL.rule
folder src-gen\testbed_sil\ or src-gen\testbed_pil\
folder target\testbed_sil\ or target\testbed_pil\
internal files which are automatically created/updated when executing a SiL- or PiL-test
But do not exclude the following files from tracing by Git (even though the report for the test coverage is not visible within the project by default ):
the POUs under test (file-name.file-extension– e.g. MyTest.iecst)
the files containing the test suites for the POUs (POU-name.robot and POU-name.xlsm)
the files for the test execution that are located in the same folder as the files containing the test suites (or in subfolders)
These files are at least: consoleLog.txt, t est report report.html, test log log.html and files containing information on the execution of the SiL-/Pil-test (e.g. test_POU-name.SiL.tstlog, summaryTestReport.SiL.xml, POU-name .SiL.xml, report for the test coverage POU-name .SiL.file-extension .gcov)