{"id":8580,"date":"2016-07-18T16:26:11","date_gmt":"2016-07-18T15:26:11","guid":{"rendered":"https:\/\/sysprogs.com\/w\/?p=8580"},"modified":"2016-07-22T04:24:45","modified_gmt":"2016-07-22T03:24:45","slug":"the-new-unit-test-support-in-visualgdb-5-2","status":"publish","type":"post","link":"https:\/\/sysprogs.com\/w\/the-new-unit-test-support-in-visualgdb-5-2\/","title":{"rendered":"The New Unit Test Support in VisualGDB 5.2"},"content":{"rendered":"<p>One of the new features introduced\u00a0in\u00a0VisualGDB 5.2 is the seamless integration of C++ unit testing frameworks into Visual Studio.\u00a0VisualGDB supports the <a href=\"http:\/\/cpputest.github.io\/\">CppUTest<\/a> and\u00a0<a href=\"https:\/\/github.com\/google\/googletest\">GoogleTest <\/a>frameworks for Linux, Android and Embedded projects\u00a0out-of-the-box and also\u00a0comes with\u00a0a powerful\u00a0customization mechanism that allows\u00a0describing any other test framework\u00a0in a way that will allow VisualGDB to discover and run\u00a0tests from it\u00a0with just\u00a0a few mouse clicks.<\/p>\n<p><a href=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/linuxtest.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8582\" src=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/linuxtest.png\" alt=\"linuxtest\" width=\"895\" height=\"662\" srcset=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/linuxtest.png 895w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/linuxtest-300x222.png 300w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/linuxtest-768x568.png 768w\" sizes=\"(max-width: 895px) 100vw, 895px\" \/><\/a><\/p>\n<p>Let&#8217;s look into the new unit test system in detail.<br \/>\n<!--more--><\/p>\n<h2>Creating projects<\/h2>\n<p>This one is really straight-forward.\u00a0We have simply added a new option called &#8220;Unit test project&#8221; to\u00a0Embedded, Linux and Android project wizards.\u00a0It automatically downloads the selected\u00a0test framework (CppUTest and GoogleTest are supported out-of-the-box) and creates a project with a few predefined tests demonstrating how to use the selected framework:<\/p>\n<p><a href=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/testprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8583\" src=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/testprj.png\" alt=\"testprj\" width=\"986\" height=\"673\" srcset=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/testprj.png 986w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/testprj-300x205.png 300w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/testprj-768x524.png 768w\" sizes=\"(max-width: 986px) 100vw, 986px\" \/><\/a><\/p>\n<p>On Android VisualGDB offers a choice between running the C++ tests inside a Java\u00a0App (the main activity will\u00a0run the tests and exit the app) or\u00a0in a stand-alone Android executable that is very lightweight, quick to build\u00a0and deploy and does not require the Java layer:<a href=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/androidtest.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8584\" src=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/androidtest.png\" alt=\"androidtest\" width=\"822\" height=\"610\" srcset=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/androidtest.png 822w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/androidtest-300x223.png 300w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/androidtest-768x570.png 768w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/p>\n<h2>Running and debugging tests<\/h2>\n<p>VisualGDB\u00a0transparently integrates the C++ testing functionality into the regular Visual Studio GUI (supported\u00a0starting from Visual Studio 2012), so you can use the regular Test Explorer window and the Test menu to\u00a0browse, run or debug your tests.\u00a0Like in C# tests, the failed test will display\u00a0what triggered the failure\u00a0along with a call stack that will help you quickly pinpoint the cause of the failure.<\/p>\n<p>We&#8217;ve also made it\u00a0very easy to debug\u00a0your tests: just select\u00a0one or more failed tests in the Test Explorer, right-click and select &#8220;Debug&#8221;. \u00a0This will automatically launch\u00a0debugging of the selected tests and once\u00a0a\u00a0failure is reported by the test, VisualGDB will intercept it and allow you to investigate:<a href=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/testfail-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-8586\" src=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/testfail-1-1024x663.png\" alt=\"testfail\" width=\"474\" height=\"307\" srcset=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/testfail-1-1024x663.png 1024w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/testfail-1-300x194.png 300w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/testfail-1-768x497.png 768w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/testfail-1.png 1132w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/a>Once you click &#8220;Break&#8221;, VisualGDB\u00a0will\u00a0stop the debug session at the time when the error happened allowing you to investigate what is going on. If the preprocessor macros used by the test framework make things unclear, you can use the &#8220;Preprocess selected lines&#8221; command to quickly expand them in-place:<a href=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/faildetail.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8587\" src=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/faildetail.png\" alt=\"faildetail\" width=\"969\" height=\"733\" srcset=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/faildetail.png 969w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/faildetail-300x227.png 300w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/faildetail-768x581.png 768w\" sizes=\"(max-width: 969px) 100vw, 969px\" \/><\/a><\/p>\n<h2>TinyEmbeddedTest<\/h2>\n<p>To support unit testing on very small embedded devices that don&#8217;t have a lot of resources we have\u00a0created a\u00a0miniature testing framework that\u00a0uses the\u00a0<a href=\"https:\/\/cpputest.github.io\/manual.html\">CppUTest<\/a> syntax and minimizes the amount of\u00a0code that needs to be run on the device. It has a FLASH memory\u00a0footprint of\u00a0less than 10KB and\u00a0is supported out-of-the-box by VisualGDB:<a href=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/tinytest.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8588\" src=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/tinytest.png\" alt=\"tinytest\" width=\"969\" height=\"733\" srcset=\"https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/tinytest.png 969w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/tinytest-300x227.png 300w, https:\/\/sysprogs.com\/w\/wp-content\/uploads\/2016\/07\/tinytest-768x581.png 768w\" sizes=\"(max-width: 969px) 100vw, 969px\" \/><\/a><\/p>\n<h2><\/h2>\n<h3>Customizing tests<\/h3>\n<p>The VisualGDB test system is designed to be easily extendable to support other test frameworks and platforms. \u00a0<a href=\"https:\/\/sysprogs.com\/w\/extending-the-visualgdb-test-system\/\">This post<\/a>\u00a0gives a detailed\u00a0explanation\u00a0of the related settings that allow using VisualGDB with any other C++ test framework.<\/p>\n<h2>Downloading<\/h2>\n<p>You can download the latest VisualGDB version with unit test support on the <a href=\"http:\/\/visualgdb.com\/download\/\">download page<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the new features introduced\u00a0in\u00a0VisualGDB 5.2 is the seamless integration of C++ unit testing frameworks into Visual Studio.\u00a0VisualGDB supports the CppUTest and\u00a0GoogleTest frameworks for Linux, Android and Embedded projects\u00a0out-of-the-box and also\u00a0comes with\u00a0a powerful\u00a0customization mechanism that allows\u00a0describing any other test framework\u00a0in a way that will allow VisualGDB to discover and run\u00a0tests from it\u00a0with just\u00a0a few &hellip; <a href=\"https:\/\/sysprogs.com\/w\/the-new-unit-test-support-in-visualgdb-5-2\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">The New Unit Test Support in VisualGDB 5.2<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[1],"tags":[216],"_links":{"self":[{"href":"https:\/\/sysprogs.com\/w\/wp-json\/wp\/v2\/posts\/8580"}],"collection":[{"href":"https:\/\/sysprogs.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sysprogs.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/w\/wp-json\/wp\/v2\/comments?post=8580"}],"version-history":[{"count":7,"href":"https:\/\/sysprogs.com\/w\/wp-json\/wp\/v2\/posts\/8580\/revisions"}],"predecessor-version":[{"id":8692,"href":"https:\/\/sysprogs.com\/w\/wp-json\/wp\/v2\/posts\/8580\/revisions\/8692"}],"wp:attachment":[{"href":"https:\/\/sysprogs.com\/w\/wp-json\/wp\/v2\/media?parent=8580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sysprogs.com\/w\/wp-json\/wp\/v2\/categories?post=8580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sysprogs.com\/w\/wp-json\/wp\/v2\/tags?post=8580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}