Command line runner for unit tests on PLCSIM Advanced. Unit test results are being stored in a jUnit compliant XML file.
Program is based on plugin system that includes plugins for
- PLCSIM Advanced
- TIA Openess
Important
To run in CI/CD pripeline or in any other unsupervised environment, access in TIA openess firewall must be granted by an administrator.
Can be done by manually choosing option to allow access during first run or by commandline option whitelist
.
- .NET Framework 4.8
- PLCSIM Advanced plugin(s)
- TIA Openess plugin(s)
Application uses Command Line Parser Library for parsing options (see https://github.com/commandlineparser/commandline for details on commandline options)
PLCSIM.UnitTest.CommandLine.exe --help
PLCSIM.UnitTest.CommandLine.exe run -v <tiaversion> -f <projectfile> -p <plcname> -o <outputfile> -t <timeout>
-v
| --version
- TIA Portal version to use
- Required
- Available options
- V16
- V17
- V18
Note
Listing plugins displays the command line option for each plugin`
-f
| --file
- Project file path (.apXX) | Project archive file path (.zapXX)
- Required
- Includes check for correct file extension depending on TIA Portal version that is being used
-p
| --plc
- Name of the PLC in the TIA project
- Required
-o
| --output
- Test result output file path
- Required
- Will automatically overwrite if exists
- Compliant to jUnit output file format (see https://github.com/testmoapp/junitxml)
-t
| --timeout
- Timeout for running unit tests
- Optional
- Default: 5m
- From starting PLC until message that unit tests finished
- In standard Timespan format
[-][d'.']hh':'mm':'ss['.'fffffff]
--verbose
- Verbose logging output
- Optional
--help
- Display help on command
PLCSIM.UnitTest.CommandLine.exe plugins
Displays
- Name
- Description
- Version
- Command line option
--verbose
- Verbose logging output
- Optional
--help
- Display help on command
Important
MUST BE RUN AS ADMIN!
PLCSIM.UnitTest.CommandLine.exe whitelist -v <listofversions>
-v
| --version
- TIA Portal versions to grant access
- Required
- Multiple version can be provided separated by space
- Available options
- V16
- V17
- V18
Note
Listing plugins displays the command line option for each plugin`
--verbose
- Verbose logging output
- Optional
--help
- Display help on command
- Load PLCSIM Advanced Plugin
- Create new PLCSIM instance
- Power on PLCSIM instance
- Load TIA Openess plugin
- Open / Deflate PLC project
- Project file name provided by commandline option
- Deflation into a temporary directory
- Compile PLC (HW & SW)
- PLC name in project provided by commandline option
- Download PLC to PLCSIM instance
- Enable simulation (if not set in project)
- Start communication with PLC
- Start PLC
- Wait for message that unit tests are finished
- Or timeout occurs (timeout time can be set by commandline option)
- Save unit test results to output file
- Output file name provided by commandline option
- Stop PLC
- Stop communication with PLC
- Power off PLCSIM instance
- Remove PLCSIM instance
- Cleanup PLCSIM Advanced instance directory
- If project was deflated from archive delete temporary directory
Note
Unit test run fails if any of the execution steps fails / produces an error.
- API v5.0 (see project "Plugin Projects/PlcSimAdvanced.V5_0")
- API v6.0 (see project "Plugin Projects/PlcSimAdvanced.V6_0")
- TIA Portal v16 (see project "Plugin Projects/TiaOpeness.V16")
- TIA Portal v17 (see project "Plugin Projects/TiaOpeness.V17")
- TIA Portal v18 (see project "Plugin Projects/TiaOpeness.V18")
- Plugin directory
- see application settings
- Debug: "<solution directory>/Plugins"
- Plugin projects copy DLL to this directory on post-build trigger
- Release: "./Plugins"
- Additional plugins can be added without recompiling main program as long as plugin contract remains the same
- Gitlab
- see Gitlab Pipeline
- Jenkins
D. Lorenz