Adding a Unit Test

Hi,

I am looking for a way to add unit tests to test some PLC code. How do I add a unit test library or solution? I tried to search for it in the Object Catalog, but could not find it. I am using AS 4.7.

Thanks and Regards,
Kenneth

You need to install the UnitTest Technology Solution, this can be done with the Upgrades dialog.

After installation this can be added from the toolbox, remember to select the version according to the GCC version you are using in the project.


After adding the solution to the project it also adds examples how to use it, and the documentation can be found from Automation Help.
Automation Help: Unit testing technology solution

2 Likes

Thanks, I will try it out.

I managed to add the technology solution for unit tests.
I was wondering where would the unit tests be run? Is it on the PLC or do we need to start ARSim?

They can be run on a real PLC or ARSim. The UnitTest technology solution adds an ARSim configuration to the project.

In a real world scenario these would most likely be run on ARSim or some test PLC. I would not include UnitTest code on a real production configuration.

1 Like

I have added in the unit test solution, however, when I compile my project, I get the error “file not recognized: File format not recognized” . Does anyone know what could be the issue?

Update: I think the issue could be because I merged the unit test solution to an existing project. For a new project, I am able to build the unit test solution.