Continuous Integration With TIA Portal - Siemens

Transcription

ContinuousIntegration withTIA Portal:Test RunnerTIA Portal / Continuous /ww/en/view/109801203SiemensIndustryOnlineSupport

Legal informationLegal informationUse of application examplesApplication examples illustrate the solution of automation tasks through an interaction of severalcomponents in the form of text, graphics and/or software modules. The application examples area free service by Siemens AG and/or a subsidiary of Siemens AG ("Siemens"). They arenon-binding and make no claim to completeness or functionality regarding configuration andequipment. The application examples merely offer help with typical tasks; they do not constitutecustomer-specific solutions. You yourself are responsible for the proper and safe operation of theproducts in accordance with applicable regulations and must also check the function of therespective application example and customize it for your system.Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have theapplication examples used by technically trained personnel. Any change to the applicationexamples is your responsibility. Sharing the application examples with third parties or copying theapplication examples or excerpts thereof is permitted only in combination with your own products.The application examples are not required to undergo the customary tests and quality inspectionsof a chargeable product; they may have functional and performance defects as well as errors. It isyour responsibility to use them in such a manner that any malfunctions that may occur do notresult in property damage or injury to persons. Siemens AG 2021 All rights reservedDisclaimer of liabilitySiemens shall not assume any liability, for any legal reason whatsoever, including, withoutlimitation, liability for the usability, availability, completeness and freedom from defects of theapplication examples as well as for related information, configuration and performance data andany damage caused thereby. This shall not apply in cases of mandatory liability, for exampleunder the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss oflife, bodily injury or damage to health, non-compliance with a guarantee, fraudulentnon-disclosure of a defect, or culpable breach of material contractual obligations. Claims fordamages arising from a breach of material contractual obligations shall however be limited to theforeseeable damage typical of the type of agreement, unless liability arises from intent or grossnegligence or is based on loss of life, bodily injury or damage to health. The foregoing provisionsdo not imply any change in the burden of proof to your detriment. You shall indemnify Siemensagainst existing or future claims of third parties in this connection except where Siemens ismandatorily liable.By using the application examples you acknowledge that Siemens cannot be held liable for anydamage beyond the liability provisions described.Other informationSiemens reserves the right to make changes to the application examples at any time withoutnotice. In case of discrepancies between the suggestions in the application examples and otherSiemens publications such as catalogs, the content of the other documentation shall haveprecedence.The Siemens terms of use (https://support.industry.siemens.com) shall also apply.Security informationSiemens provides products and solutions with Industrial Security functions that support the secureoperation of plants, systems, machines and networks.In order to protect plants, systems, machines and networks against cyber threats, it is necessaryto implement – and continuously maintain – a holistic, state-of-the-art industrial security concept.Siemens’ products and solutions constitute one element of such a concept.Customers are responsible for preventing unauthorized access to their plants, systems, machinesand networks. Such systems, machines and components should only be connected to anenterprise network or the Internet if and to the extent such a connection is necessary and onlywhen appropriate security measures (e.g. firewalls and/or network segmentation) are in place.For additional information on industrial security measures that may be implemented, please emens’ products and solutions undergo continuous development to make them more secure.Siemens strongly recommends that product updates are applied as soon as they are availableand that the latest product versions are used. Use of product versions that are no longersupported, and failure to apply the latest updates may increase customer’s exposure to cyberthreats.To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feedat: ous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/20212

Table of contentsTable of contentsLegal information . 212 Siemens AG 2021 All rights reserved3Introduction . 41.1Overview. 41.2Components used . 41.3Restrictions . 5Description . 62.1Areas of application . 62.22.2.12.2.22.2.3Principle of operation. 6Parameter overview . 6Parameter explanation . 7Example calls . 102.3Report . 11Appendix . 123.1Service and support . 123.2Industry Mall . 133.3Links and literature . 133.4Change documentation . 13Continuous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/20213

1 Introduction1Introduction1.1OverviewLaunching Test Runner allows you to test program code with the TIA Portal TestSuite option. In the process, previously defined style guide rules and applicationtests are run automatically and a report of the results is written to a file.Test Runner uses the TIA Portal Test Suite option in conjunction with TIA Portalversion 17 or higher.1.2Components usedThe following hardware and software components were used to create thisapplication example:Table 1-1ComponentQuantity Siemens AG 2021 All rights reservedTIA Portal V17Step 7TIA Portal TestSuite optionItem numberNote16ES7822-1A.07-.Requires license16ES7823-1TE07-0AA5Requires licenseArticle ID for download:109793099This application example consists of the following components:Table 1-2ComponentFile nameNoteTest Runnerdocumentation109801203 Cont Int TestRunner DOC V10 en.pdfThisdocumentTest RunnerV1.3.1109801203 Cont Int TestRunner PROJ V10.zipDLLs,applicationBAT files forintegration109801203 Cont Int Setup PROJ V11.zipOptional: BATfiles forintegratingTest Runnerinto JenkinsSetupdocumentation109801203 Cont Int Setup DOC V11 en.pdfOptional: CIsystem setupJenkinsdocumentation109801203 Cont Int Jenkins DOC V11 en.pdfOptional:JenkinsReadme OSSReadMe OSS.htmlThird-partysoftwareinformationContinuous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/20214

1 Introduction1.3RestrictionsTest Runner uses the TIA Portal Test Suite option and is mandatory if you wish touse the component. TIA Portal V17 or higher is a prerequisite for the component. Siemens AG 2021 All rights reservedUsing Test Runner, it is currently not possible to run application tests for which thescope is a PLC with activated F operation. This also means that Test Runnercannot test safety program code. Testing controllers with active F operation is onlypossible with the TIA Portal user interface.Continuous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/20215

2 Description2Description2.1Areas of applicationTest Runner is used to verify and/or test program code with the style guide rulesand application tests previously defined in the project. The style guide rules andapplication tests are defined with the Test Suite option and run with Test Runnervia a command-line interface (CLI). This implementation can be accomplished inthe continuous integration context, or as a standalone application.2.2Principle of operationTest Runner is launched with the appropriate parameter and does not need to beconfigured separately.Test Runner is controlled with the Windows Command Prompt or as a batch script.You can launch it by right-clicking the application folder with the SHIFT key helddown, then selecting "Open Command Prompt here".2.2.1Parameter overviewTable 2-1: Parameter overview Siemens AG 2021 All rights reservedLong formShort --final-behavior CLOSE KEEP INSTANCE KEEP PROJECT -x CLOSE KEEP INSTANCE KEEP PROJECT ---project TiaProjectFilePath -p TiaProjectFilePath X--report FilePath -r FilePath X--format XML JUNIT JUNIT HUDSON -f XML JUNIT JUNIT HUDSON X--logfile FilePath -l FilePath ---test-application ListOfTestCasesSpacesSeparated all -a ListOfTestCasesSpacesSeparated all X--test-application-plc-scope PlcName -b PlcName --test-style ListOfRuleSetSpaceSeparated all -s ListOfRuleSetSpaceSeparated all X--test-style-plc-scope PlcName -t PlcName --In general, two spellings or formats are allowed for passing the arguments.For example, the following versions are possible for "report":--report FilePath oder --report FilePath Continuous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/20216

2 Description2.2.2Parameter explanationParameter --helpThis outputs the console application's help text, which contains a short descriptionof the parameters from Table 2-1.Parameter --versionThis outputs the current version number of the console application.Parameter –-quiet or -qThis will suppress the log output in the console window. In this case, the log entrieswill only be written to the log file, to the extent this has been specified.Parameter --debug or -dThis will launch TIA Portal with user interface when the application is launched, inorder to facilitate debugging when running the tests.Parameter --final-behavior or -x Siemens AG 2021 All rights reservedThis defines what is to happen to the TIA Portal and project after testing. Thisserves to speed up the execution of the tests, since TIA Portal and the project mayno longer have to be opened separately and test execution is also faster. Thefollowing options are available: The project and the TIA Portal instance are closed (CLOSE). The project is closed, the TIA Portal instance is kept (KEEP INSTANCE). The project and the TIA Portal instance are kept (KEEP PROJECT).When the application is started, a search is made for an open TIA Portal instance.If an instance is found where the project to be tested is already open, this instanceis used. If an instance is found where no project is open yet, this instance is used,and the project is opened. Otherwise, a TIA Portal instance is created and theproject to be tested is opened in it.NOTESince Jenkins automatically closes the instances created by its processes at theend of a build, the TIA Portal instance must be manually opened in advance forreuse.Parameter --project or -pThis is used to specify the project that will be tested. The project must be a singleuser project.This parameter is mandatory.Example call:--project "D:\Projects\Library Master\Library Master.ap17"Continuous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/20217

2 DescriptionParameter --report or -rThis passes the desired file path for reporting. When the application has finishedrunning, a report from all verifications and tests will be generated as an XML file.The report is based on the output of the test suite when run manually within TIAPortal.The XML file can be generated according to various formats. This is defined withthe --format parameter.This parameter is mandatory.Example call:--report "D:\Test\report.xml"Parameter --format or -fThis defines the type or formatting of the XML report file.This parameter is mandatory. Siemens AG 2021 All rights reservedThe following formats are available: as a proprietary XML (XML) as XML on the basis of the JUNIT format (JUNIT) as XML on the basis of the JUNIT format for Hudson or Jenkins(JUNIT HUDSON)Example call:--format JUNIT HUDSONParameter --logfile or -lThis passes the desired file path for saving the logs. The log documents all stepsthat were run and any errors that occurred during the execution.Example call:--logfile "D:\Test\runner.log"Parameter --test-application or -aThis selects the application tests which will be run as defined in the project. A list ofapplication tests or test cases can be passed, or just a single one. To do this, eitherthe name of the application test you wish to run must be passed or a series ofapplication test names separated by spaces. If the name contains one or morespaces, the name must be placed in quotation marks.The keyword all will cause all defined application tests to be run.This parameter is mandatory.Example calls:--test-application TestCase1 TestCase2--test-application allContinuous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/20218

2 DescriptionParameter --test-application-plc-scope or -bThis selects the test suite scope for the selected application tests. The Scopeparameter sets the scope which will be passed for all selected application tests.The Scope is a CPU name which must be defined in the project and accordingly itmust contain the appropriate block calls for the selected application tests. If theScope is not set with the parameter, the default Scope of the respective applicationtest will be used. In this case, the Scope in the application test must not be empty.Example call:--test-application-plc-scope StandardPlcParameter --test-style or -sThis selects the style guide rule sets to be run as defined in the project. A list ofstyle guide rule sets can be passed, or just a single one. To do this, either thename of the style guide rule set you wish to check must be passed or a series ofstyle guide rule set names separated by spaces. If the name contains one or morespaces, the name must be placed in quotation marks.The keyword all will cause all defined style guide rule sets to be run.This parameter is mandatory.Example call:--test-style MyStandardRuleSet "Siemens StyleGuide Rule set" Siemens AG 2021 All rights reserved--test-style allParameter --test-style-plc-scope or -tThis selects the test suite scope for the selected style guide rule sets. The Scopeparameter sets the scope which will be passed at CPU level for all selected styleguide rule sets. The Scope is a CPU name which must be defined in the projectand accordingly it must contain the appropriate block calls for the selectedapplication tests. If the Scope is not set with the parameter, the default Scope ofthe respective style guide rule set will be used.Example call:--test-style-plc-scope StandardPlcNoteWith the parameter above, it is only possible to set the Scope at the PLC level. Ifa more granular Scope setting is desired, this must be set in the TIA Portalinterface and saved. Then the parameter above can be omitted. This will causethe default scope from the project to be used.Continuous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/20219

2 Description2.2.3Example callsThe following demonstrates commonly used Test Runner launches. The examplesall include the full log output in the console window and a generated log file.The character is used for line breaks in the console to achieve a more readablewindow.Run all application tests and style guide rule sets with default scopeExample input:Siemens.TestRunnerConsole.exe -project "D:\Projects\Master Library\Master Library.ap17" --logfile "D:\Temp\runner.log" --report "D:\Temp\report.xml" --test-application all --test-style allRun specific application tests and style guide rule sets with default scopeExample input:Siemens.TestRunnerConsole.exe -project "D:\Projects\Master Library\Master Library.ap17" Siemens AG 2021 All rights reserved--logfile "D:\Temp\runner.log" --report "D:\Temp\report.xml" --test-application TestCaseName1 "TestCase with blanks" --test-style "Rule set Standard"Run specific application tests with a newly defined scopeExample input:Siemens.TestRunnerConsole.exe -project "D:\Projects\Master Library\Master Library.ap17" --logfile "D:\Temp\runner.log" --report "D:\Temp\report.xml" --test-application TestCaseName1 "TestCase with blanks" --test-application-plc-scope StandardPlcContinuous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/202110

2 Description2.3ReportAfter being run, Test Runner provides a test report about the style guide rules itchecked and application tests it ran. The report is generated on the basis of thetest results from the TIA Portal Test Suite. When run manually in the TIA Portalinterface, these results can be viewed in the Inspector window under Info Testresults. Siemens AG 2021 All rights reservedFigure 2-1: TIA Portal Inspector windowWhen checking the style guide, "localhost" will be entered in the report by"Environment" or "Hostname" because the verification of the rules took placedirectly on the PC, i.e. the localhost. With the application test, on the other hand,the tests are run on a virtual instance of PLCsim Adv. and it will adjust to match theconfigured PLC, meaning that the CPU name will be entered by "Environment" or"Hostname".There are currently 3 report formats in all: Proprietary XML (XML) XML on the basis of the JUNIT format (JUNIT) XML on the basis of the JUNIT format for Hudson or Jenkins(JUNIT HUDSON)Continuous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/202111

3 Appendix3Appendix3.1Service and supportIndustry Online SupportDo you have any questions or need assistance?Siemens Industry Online Support offers round the clock access to our entireservice and support know-how and portfolio.The Industry Online Support is the central address for information about ourproducts, solutions and services.Product information, manuals, downloads, FAQs, application examples and videos– all information is accessible with just a few mouse clicks:support.industry.siemens.comTechnical SupportThe Technical Support of Siemens Industry provides you fast and competentsupport regarding all technical queries with numerous tailor-made offers– ranging from basic support to individual support contracts.Please send queries to Technical Support via Web form: Siemens AG 2021 All rights reservedsiemens.com/SupportRequestSITRAIN – Digital Industry AcademyWe support you with our globally available training courses for industry withpractical experience, innovative learning methods and a concept that’s tailored tothe customer’s specific needs.For more information on our offered trainings and courses, as well as theirlocations and dates, refer to our web page:siemens.com/sitrainService offerOur range of services includes the following: Plant data services Spare parts services Repair services On-site and maintenance services Retrofitting and modernization services Service programs and contractsYou can find detailed information on our range of services in the service catalogweb page:support.industry.siemens.com/cs/scIndustry Online Support appYou will receive optimum support wherever you are with the "Siemens IndustryOnline Support" app. The app is available for iOS and 067Continuous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/202112

3 Appendix3.2Industry MallThe Siemens Industry Mall is the platform on which the entire siemens Industryproduct portfolio is accessible. From the selection of products to the order and thedelivery tracking, the Industry Mall enables the complete purchasing processing –directly and independently of time and location:mall.industry.siemens.com3.3Links and literatureTable 3-1 Siemens AG 2021 All rights reservedNo.3.4Subject\1\Siemens Industry Online Supporthttps://support.industry.siemens.com\2\Link to the article page of the application en/view/109801203\3\TIA Portal Test Suite Advanced V17 Trial /en/view/109793099\4\TIA Portal Test Suite function n/view/109779356\5\Jenkins user documentationhttps://jenkins.io/doc/\6\Windows ndsChange documentationTable 3-2VersionDateV1.011/2021Continuous Integration - Test RunnerArticle ID: 109801203, V1.0, 11/2021ChangeFirst version13

Launching Test Runner allows you to test program code with the TIA Portal Test Suite option. In the process, previously defined style guide rules and application tests are run automatically and a report of the results is written to a file. Test Runner uses the TIA Portal Test Suite option in conjunction with TIA Portal version 17 or higher.