<?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>Unable to Run ZTest Unit Tests on nRF Sample – native_sim Not Detected by Twister</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/121613/unable-to-run-ztest-unit-tests-on-nrf-sample-native_sim-not-detected-by-twister</link><description>Hello everyone, 
 I would like to learn how to create unit tests using the ZTest framework for a Nordic sample project, in order to better understand how it works. 
 I am currently working on a Linux (Ubuntu) machine, as I understand from the documentation</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 04 Jun 2025 09:44:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/121613/unable-to-run-ztest-unit-tests-on-nrf-sample-native_sim-not-detected-by-twister" /><item><title>RE: Unable to Run ZTest Unit Tests on nRF Sample – native_sim Not Detected by Twister</title><link>https://devzone.nordicsemi.com/thread/538012?ContentTypeID=1</link><pubDate>Wed, 04 Jun 2025 09:44:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56f1c23c-bddd-456c-9222-1c36146a60ef</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;You can start by looking at&amp;nbsp;&lt;a href="https://docs.zephyrproject.org/latest/develop/test/ztest.html#quick-start-unit-testing"&gt;Unit Testing Quick Start&lt;/a&gt;.&amp;nbsp;&lt;span&gt;&amp;quot;type:unit&amp;quot; in test yaml means it is supposed to only run on &amp;quot;unit_testing&amp;quot; platform. This is a setup to load only minimal functionality from zephyr to allow building apps and executing them with mocks on your host. Please note that native_posix is depricated (native_sim replaces it). Native_sim is a &amp;quot;full&amp;quot; platform, and that is why a lot of stuff will be missing when one starts with &amp;quot;unit_testing&amp;quot;. Unit tests (using the board unit_testing) are intended to run on your host system and thus are a bit different than running on embedded target. There are some tests in Zephyr that&amp;nbsp;can be built both using unit_testing as the target board or targeting an embedded target. Here is one&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/tests/subsys/testsuite/fff_fake_contexts/CMakeLists.txt"&gt;example&lt;/a&gt;&amp;nbsp;of such tests.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Run ZTest Unit Tests on nRF Sample – native_sim Not Detected by Twister</title><link>https://devzone.nordicsemi.com/thread/537607?ContentTypeID=1</link><pubDate>Mon, 02 Jun 2025 08:17:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:267a4c83-6613-4c4f-b87b-72d03c3c5f1a</guid><dc:creator>SemihAydin</dc:creator><description>&lt;p&gt;Hİ Dejan,&lt;br /&gt;&lt;br /&gt;I uninstalled all folders belongs to zephyr and nRF like ncs, nrf connect from vs code and zephyr folders from computer, then I installed them again I also removed the zephyr&amp;#39;s path from the /.bashrc. After this process, result wasn&amp;#39;t different. However, I decided to open some space in my computer because it was around 100-200MB space left. I opened more than 5GB space and this time result was different, I didn&amp;#39;t get any error with native_sim.&lt;br /&gt;&lt;br /&gt;This is good part, but now I have a different question.&lt;br /&gt;&lt;br /&gt;I copied the intmath test from &lt;a id="" href="https://github.com/nrfconnect/sdk-zephyr/tree/v4.0.99-ncs1/tests/unit"&gt;https://github.com/nrfconnect/sdk-zephyr/tree/v4.0.99-ncs1/tests/unit&lt;/a&gt; to see if my tests are wrong.&lt;br /&gt;&lt;br /&gt;Here are the results,&lt;br /&gt;&lt;br /&gt;native_sim and native_posix: I just added the necessary platform_allow and harness informations to the testcase.yaml file and tried to run with it. There are no error but tests are not executed. If I add build_only: false or build_only: true option, results are the same with native platforms.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; platform_allow:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - native_sim&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - native_posix&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; harness: ztest&lt;br /&gt;&lt;br /&gt;My run commands are:&lt;br /&gt;python3 /home/sirdarwin/ncs/v3.0.0/zephyr/scripts/twister -p native_posix -T /home/sirdarwin/multi_service/tests/unit/intmath -v&lt;br /&gt;&lt;br /&gt;python3 /home/sirdarwin/ncs/v3.0.0/zephyr/scripts/twister -p native_sim -T /home/sirdarwin/multi_service/tests/unit/intmath -v&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1748850999019v1.png" alt=" " /&gt;&lt;br /&gt;&lt;br /&gt;unit_testing: This platform is working as expected, I run the command &amp;quot;python3 /home/sirdarwin/ncs/v3.0.0/zephyr/scripts/twister -p unit_testing -T /home/sirdarwin/multi_service/tests/unit/intmath -v&amp;quot; and its working properly, even if I add build_only: false to the testcase.yaml file here is the result,&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1748851494864v2.png" alt=" " /&gt;&lt;br /&gt;&lt;br /&gt;Can I assume that this unit test worked properly? because I didn&amp;#39;t added the unit_testing platform.&lt;br /&gt;What is the difference between unit_testing platform and native platforms? &lt;br /&gt;Can I use that unit_testing platform for my all types of unit testing, I&amp;#39;m also open for another recommendations?&lt;br /&gt;Why its not execute in native platforms?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Run ZTest Unit Tests on nRF Sample – native_sim Not Detected by Twister</title><link>https://devzone.nordicsemi.com/thread/536330?ContentTypeID=1</link><pubDate>Wed, 21 May 2025 07:41:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6cdbd45-2b2b-4904-874f-7e8921c69034</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Semih,&lt;/p&gt;
[quote user="SemihAydin"]I will try to uninstall other toolchain then I will&amp;nbsp;keep you updated.[/quote]
&lt;p&gt;Thank you. I am waiting for your update.&lt;br /&gt;&lt;br /&gt;As it seems that twister cannot find boards from Zephyr root, you could try to add &amp;quot;--board-root&amp;quot; to your twister command. You can use &amp;quot;west twister --help&amp;quot; to get more information.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Run ZTest Unit Tests on nRF Sample – native_sim Not Detected by Twister</title><link>https://devzone.nordicsemi.com/thread/536280?ContentTypeID=1</link><pubDate>Tue, 20 May 2025 19:57:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c3dc61d-a25b-44ea-abcf-0599ab04c4b1</guid><dc:creator>SemihAydin</dc:creator><description>&lt;p&gt;Hi Dejans,&lt;br /&gt;&lt;br /&gt;Thank you&amp;nbsp;so much for your reply.&lt;br /&gt;&lt;br /&gt;I&amp;#39;m sure that I&amp;#39;m using same toolchain(v3.0.0) but there are two toolchain installed other one is v2.9.0&lt;br /&gt;&lt;br /&gt;As I mentioned that&amp;nbsp;&lt;span&gt;I&amp;#39;m checking my&amp;nbsp;&lt;/span&gt;&lt;code&gt;ZEPHYR_BASE&lt;/code&gt;&lt;span&gt;&amp;nbsp;by running: echo $ZEPHYR_BASE on terminal and I&amp;#39;m getting&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;quot;/home/sirdarwin/ncs/v3.0.0/zephyr&amp;quot; at the terminal output.&lt;br /&gt;&lt;br /&gt;I will try to uninstall other toolchain then I will&amp;nbsp;keep you updated.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Semih&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to Run ZTest Unit Tests on nRF Sample – native_sim Not Detected by Twister</title><link>https://devzone.nordicsemi.com/thread/536253?ContentTypeID=1</link><pubDate>Tue, 20 May 2025 14:30:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a875503a-31d1-4c89-ac6d-d840225f81cb</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Semih,&lt;br /&gt;&lt;br /&gt;Are you sure that you have and use correct Toolchain?&lt;br /&gt;&lt;br /&gt;It could also be worth double-checking that you have set correct ZEPHYR_BASE because in you case it seems that twister does not see boards from the Zephyr&amp;#39;s root.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>