<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Unity Test Framework - Adding multiple test files</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61679/unity-test-framework---adding-multiple-test-files</link><description>Hello, 
 I am trying to integrate the Unity test framework into our project and running into issues with how to add additional test files. Nordic provides one example project in the nRF Connect SDK repository here: https://github.com/nrfconnect/sdk-nrf</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 07 Oct 2020 09:21:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61679/unity-test-framework---adding-multiple-test-files" /><item><title>RE: Unity Test Framework - Adding multiple test files</title><link>https://devzone.nordicsemi.com/thread/273413?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 09:21:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6471e997-ad1e-458a-8380-939a6a8a96c1</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Cody,&lt;/p&gt;
[quote user="CRSharff"]just to confirm, every time I &amp;quot;split them out logically into multiple test projects&amp;quot; I am going to need a new CMakeLists.txt, Kconfig, and prj.conf for each test file to which CMake/Make is ran across and a new binary is generated?[/quote]
&lt;p&gt;Yes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Amanda H.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unity Test Framework - Adding multiple test files</title><link>https://devzone.nordicsemi.com/thread/272617?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 16:39:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:041ff81d-3db1-4a7a-a0b2-00442413467a</guid><dc:creator>Cody</dc:creator><description>&lt;p&gt;Okay, just to confirm, every time I &amp;quot;split them out logically into multiple test projects&amp;quot; I am going to need a new CMakeLists.txt, Kconfig, and prj.conf for each test file to which CMake/Make is ran across and a new binary is generated?&lt;br /&gt;&lt;br /&gt;Looking at a Unity sample located at&amp;nbsp;&lt;a href="https://github.com/ThrowTheSwitch/Unity/tree/master/examples/example_1"&gt;https://github.com/ThrowTheSwitch/Unity/tree/master/examples/example_1&lt;/a&gt;&amp;nbsp;it would be nice if I could organize in a similar fashion. I think the limitation might exist as part of the the nRF Connect SDK&amp;#39;s Unity helper functions located in&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/tests/unity/CMakeLists.txt"&gt;https://github.com/nrfconnect/sdk-nrf/blob/master/tests/unity/CMakeLists.txt &lt;/a&gt;and less so on Unity based on the example project.&lt;br /&gt;&lt;br /&gt;Thanks for your continued assistance,&lt;br /&gt;Cody&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unity Test Framework - Adding multiple test files</title><link>https://devzone.nordicsemi.com/thread/272509?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 12:08:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57118b7e-2d14-429e-b0f4-b43b6d369470</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Cody,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I got the following from the developer:&lt;/p&gt;
&lt;p&gt;so it&amp;#39;s a limitation of unity, there is one runner for one test file generated. there can be multiple uut_2.c files attached to the project but only one test file. Imo, if there are too many tests for a single file there, I would try to split them logically into multiple test projects for the same module.&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unity Test Framework - Adding multiple test files</title><link>https://devzone.nordicsemi.com/thread/272397?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 23:17:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba1af209-e997-48da-8e57-428313f6e480</guid><dc:creator>Cody</dc:creator><description>&lt;p&gt;Hey &lt;a href="https://devzone.nordicsemi.com/members/amanda"&gt;Amanda Hsieh&lt;/a&gt;,&lt;br /&gt;&lt;br /&gt;I know it has been quite some time since my last update but I am still having troubles with this.&lt;br /&gt;&lt;br /&gt;Using the Unity test example located in the nRF Connect SDK here:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/master/tests/unity/example_test"&gt;https://github.com/nrfconnect/sdk-nrf/tree/master/tests/unity/example_test&lt;/a&gt;, if the developer wanted to add an additional file to the module, say src/uut/uut_2.c, and the developer wanted to test the functions in this file with the same test project how would the developer go about doing this?&lt;br /&gt;&lt;br /&gt;One way to do so would be to modify the CMakeLists.txt:&lt;/p&gt;
&lt;p&gt;# add module uut&lt;br /&gt;target_sources(app PRIVATE src/uut/uut.c)&lt;br /&gt;&lt;span&gt;target_sources(app PRIVATE src/uut/uut_2.c) &amp;lt;-- add new source file here&lt;/span&gt;&lt;br /&gt;target_include_directories(app PRIVATE ./src/uut)&lt;/p&gt;
&lt;p&gt;and then add additional test functions inside example_test.c but that can get huge really fast, even though both source files are part of the same module it is still hard to organize.&lt;br /&gt;&lt;br /&gt;If you try to add example_test_2.c to the project to organize all tests for uut_2.c inside of, when you add &amp;quot;&lt;span&gt;test_runner_generate(src/example_test_2.c)&amp;quot; to CMakeLists.txt you will get an error during compilation. This is due to the fact that, as you said previously, the script only accepts one file.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;In summary, even though I have nicely organized modules as part of my project, the Unity test project for the modules requires that you only have one test file for the entire module. This &amp;quot;test runner&amp;quot; file gets huge and does not allow for organization of specific files inside the module.&lt;br /&gt;&lt;br /&gt;Has anyone at Nordic ran into this and can provide a solution and/or workaround?&lt;br /&gt;&lt;br /&gt;Thanks,&lt;br /&gt;Cody&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unity Test Framework - Adding multiple test files</title><link>https://devzone.nordicsemi.com/thread/252369?ContentTypeID=1</link><pubDate>Fri, 29 May 2020 10:55:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:819717bf-43a2-4c68-925e-6de0bd81498e</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Cody,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes, in theory, you can create two tests for the same module.&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unity Test Framework - Adding multiple test files</title><link>https://devzone.nordicsemi.com/thread/252268?ContentTypeID=1</link><pubDate>Thu, 28 May 2020 16:55:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2dd2f85-2475-429d-a547-c78e1f9a3183</guid><dc:creator>Cody</dc:creator><description>&lt;p&gt;Okay, my project does have multiple modules that I have separated out. Just to clarify, when you mention &amp;quot;module&amp;quot; you are speaking to a grouping of source files referenced in a CMakeLists.txt? For example, in the asset_track sample application, gps_controller and env_sensors would be considered &amp;quot;modules&amp;quot;?&lt;br /&gt;&lt;br /&gt;I will try implementing it in this way and get back to you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unity Test Framework - Adding multiple test files</title><link>https://devzone.nordicsemi.com/thread/252087?ContentTypeID=1</link><pubDate>Thu, 28 May 2020 07:33:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7bf02de3-931f-4008-8604-7ebbd859fc24</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Cody,&lt;/p&gt;
&lt;p&gt;In general, you have one file per module, so multiple test binaries for the project.&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unity Test Framework - Adding multiple test files</title><link>https://devzone.nordicsemi.com/thread/251788?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 19:17:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63a51e9f-713c-43a0-9d9f-1a7cfe2a5c35</guid><dc:creator>Cody</dc:creator><description>&lt;p&gt;Have one file with all the tests? What if I have hundreds of tests for my project, that file is going to be huge.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unity Test Framework - Adding multiple test files</title><link>https://devzone.nordicsemi.com/thread/251432?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 09:27:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fafcf498-99c5-466a-8cf0-916d4517df6a</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Cody,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It seems like unity framework limitation:&amp;nbsp;&lt;a href="https://github.com/ThrowTheSwitch/Unity/blob/b0032caca4402da692548f2ee296d3b1b1251ca0/auto/generate_test_runner.rb#L484"&gt;https://github.com/ThrowTheSwitch/Unity/blob/b0032caca4402da692548f2ee296d3b1b1251ca0/auto/generate_test_runner.rb#L484&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The script accepts only one file. You&amp;nbsp;should create a test case sample, similar to &lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/master/tests/unity/example_test"&gt;example_Test&lt;/a&gt;, and have there one file with tests.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>