# Adding a Unit Test

**URL:** <https://community.br-automation.com/t/adding-a-unit-test/5247>\
**Category:** B&R Software & Runtime\
**Tags:** automation-studio, units-testing\
**Created:** [December 17, 2024, 5:14am UTC](https://community.br-automation.com/t/adding-a-unit-test/5247 "2024-12-17T05:14:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenneth.tham](https://avatars.discourse-cdn.com/v4/letter/k/FF8800/32.png) [@kenneth.tham](https://community.br-automation.com/u/kenneth.tham)\
**Post date:** [December 17, 2024, 5:14am UTC](https://community.br-automation.com/t/adding-a-unit-test/5247/1 "2024-12-17T05:14:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tommi.piiparinen](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/tommi.piiparinen/32/2183_2.png) [@tommi.piiparinen](https://community.br-automation.com/u/tommi.piiparinen)\
**Post date:** [December 17, 2024, 6:24am UTC](https://community.br-automation.com/t/adding-a-unit-test/5247/2 "2024-12-17T06:24:43Z")

</div>

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

 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/a/ab7ea51a0466671f92ac0f0b314b65fceafbc68d.png)

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.

 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/a/ac3f89822ea847f3c9c47c84d53f24317b67ce4f.png)  
 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/b/b87723cecd4209e6759108e3ca97f8a7f01d817c.png)

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](https://help.br-automation.com/#/en/4/technologysolutions%2Fts_unittest%2Fgeneral%2Fts_unittest.html)

---

<div class="post-metadata">

**Author:** ![kenneth.tham](https://avatars.discourse-cdn.com/v4/letter/k/FF8800/32.png) [@kenneth.tham](https://community.br-automation.com/u/kenneth.tham)\
**Post date:** [December 18, 2024, 1:53am UTC](https://community.br-automation.com/t/adding-a-unit-test/5247/3 "2024-12-18T01:53:11Z")

</div>

Thanks, I will try it out.

---

<div class="post-metadata">

**Author:** ![kenneth.tham](https://avatars.discourse-cdn.com/v4/letter/k/FF8800/32.png) [@kenneth.tham](https://community.br-automation.com/u/kenneth.tham)\
**Post date:** [December 18, 2024, 10:22am UTC](https://community.br-automation.com/t/adding-a-unit-test/5247/4 "2024-12-18T10:22:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tommi.piiparinen](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/tommi.piiparinen/32/2183_2.png) [@tommi.piiparinen](https://community.br-automation.com/u/tommi.piiparinen)\
**Post date:** [December 18, 2024, 10:24am UTC](https://community.br-automation.com/t/adding-a-unit-test/5247/5 "2024-12-18T10:24:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kenneth.tham](https://avatars.discourse-cdn.com/v4/letter/k/FF8800/32.png) [@kenneth.tham](https://community.br-automation.com/u/kenneth.tham)\
**Post date:** [December 19, 2024, 5:25am UTC](https://community.br-automation.com/t/adding-a-unit-test/5247/6 "2024-12-19T05:25:58Z")

</div>

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.
