{"id":4280,"date":"2019-06-11T12:13:50","date_gmt":"2019-06-11T10:13:50","guid":{"rendered":"https:\/\/zen-cori.138-201-132-86.plesk.page\/?p=4280"},"modified":"2023-02-06T12:38:20","modified_gmt":"2023-02-06T10:38:20","slug":"what-are-the-differences-between-functional-and-structural-test-cases","status":"publish","type":"post","link":"https:\/\/www.btc-embedded.com\/zh-hans\/what-are-the-differences-between-functional-and-structural-test-cases\/","title":{"rendered":"What are the differences between functional and structural test cases?"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"4280\" class=\"elementor elementor-4280\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3b5f0493 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3b5f0493\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-559a247a\" data-id=\"559a247a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d83c847 elementor-widget elementor-widget-text-editor\" data-id=\"d83c847\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>When it comes to unit testing in automotive industries, the first use case most people have in mind is functional testing. Basically, this means to take all requirements that belong to a certain unit and write test cases to verify if the unit works as expected. However, there are also structural test cases that are derived from e.g. code coverage goals. Let&#8217;s have a look what are the differences of functional and structural test cases.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7c099a8 elementor-widget elementor-widget-heading\" data-id=\"7c099a8\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Functional test cases<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a1ff07f elementor-widget elementor-widget-text-editor\" data-id=\"a1ff07f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>As already mentioned, these test cases are derived from the requirements and a single test case represents one \u201cgood run\u201d through the system-under-test that covers a certain aspect of the unit. They are a translation of a textual requirement into a data stream that can be used for simulation. To verify the expected behavior the tester stimulates the system-under-test by defining a certain input behavior and then observes the expected results at the affected outputs during a simulation of the model and possibly code.<\/p><p>Due to its characteristic, the test cases can become quite long to cover a specific behavior, and the requirement usually only describes the expected behavior of the affected output signals and &#8211; if available &#8211; internal measurement points. Furthermore, even if the requirement describes the expected behavior of an output signal, it might only give information about a temporal section over the whole length of the test case. The unaffected signals are usually treated as \u201cDon\u2019t care\u201d as well as not defined temporal sections of a signal.<\/p><p>Once all test cases that belong to one requirement are executed successfully, the requirement is counted as tested. Even though there are a lot of new testing techniques on the market today, functional testing is the standard test method to verify the functional behavior of a system-under-test.<\/p><p>Now let&#8217;s have a look at the structural test cases to get a better understanding of the\u00a0<span style=\"color: var( --e-global-color-text ); letter-spacing: 0px; background-color: var( --e-global-color-8c64e01 );\">differences of functional and structural test cases.<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-27e953f elementor-widget elementor-widget-heading\" data-id=\"27e953f\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Structural test cases<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6cdaf06 elementor-widget elementor-widget-text-editor\" data-id=\"6cdaf06\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Structural test cases are usually derived from code coverage goals like Statement, Decision, MD\/DC. Even though you can write them manually, there are several tools available today that are able to generate test cases automatically. They can be put in two categories.<\/p><ol><li>Random test case generation<br \/>The test cases are generated by selecting input data randomly and check the reached coverage afterward. This approach is never complete and might lead to very long structural test cases that are hard to debug. But then, its advantage is to be fast for generating the test cases. Basically, all tools provide this approach.<\/li><li>Model Checking based test case generation<br \/>This smart approach is complete, always provides the shortest possibility to cover a certain coverage goal and can even proof that a certain coverage goal can never be reached (unreachable proof). Due to this, it is slower than the random test case generation. Have a look at our\u00a0<a href=\"https:\/\/www.btc-embedded.com\/interview-how-does-a-model-checker-work\/\" target=\"_blank\" rel=\"noopener\">Model Checking<\/a>\u00a0page for more details. Only very few tools provide this advanced smart approach.<\/li><\/ol><div>\u00a0<\/div><p>Might this replace the admittedly time-consuming manual test case creation?<\/p><p>The simple answer is: No!<\/p><p>The full answer is: It depends!<\/p><p>If a machine-readable representation of a requirement is provided (this is called a formalized requirement), the\u00a0Model Checking\u00a0technology is able to generate functional test cases. To get more information about this approach, please have a look at the\u00a0<a href=\"https:\/\/www.btc-embedded.com\/use_cases\/formal-specification\/\" target=\"_blank\" rel=\"noopener\">BTC EmbeddedSpecifier<\/a>.<\/p><p>But let\u2019s assume for now that we do not have a formal representation of the requirements. What is the purpose of these automatically created structural test cases, if they do not replace the functional testing?<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8f3060b elementor-widget elementor-widget-heading\" data-id=\"8f3060b\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">What are structural test cases?<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6ec190f elementor-widget elementor-widget-text-editor\" data-id=\"6ec190f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Let\u2019s quickly remember that for functional testing the requirements are the source of information the test cases are derived from, even for formalized requirements. This is similar for automatically generated structural test cases, but the source of information is different and brings us to the\u00a0<span style=\"color: var( --e-global-color-text ); font-family: var( --e-global-typography-text-font-family ), Sans-serif; font-size: var( --e-global-typography-text-font-size ); font-style: var( --e-global-typography-text-font-style ); letter-spacing: var( --e-global-typography-text-letter-spacing ); text-transform: var( --e-global-typography-text-text-transform ); text-decoration: var( --e-global-typography-text-text-decoration ); background-color: var( --e-global-color-8c64e01 );\">differences of functional and structural test cases.<\/span><\/p><p>The tools do not take the requirements but structural properties of the system-under-test into account as the source of the test case generation. There is a wide range of possible structural properties that can be taken into account to be covered by automatically generated test cases. Basically, they are all about model or code coverage. The most common coverage goals are statement, branch or decision, condition and modified decision\/condition coverage (MC\/DC) (also requested by\u00a0<a href=\"https:\/\/www.btc-embedded.com\/use_cases\/iso-26262\/\" target=\"_blank\" rel=\"noopener\">ISO 26262<\/a>) and there are a lot more like function coverage, equivalence classes or individually specified coverage goals. Please, have a look at this\u00a0<a href=\"https:\/\/www.btc-embedded.com\/what-you-should-know-about-code-coverage\/\" target=\"_blank\" rel=\"noopener\">blog article that talks about code coverage<\/a>.<\/p><p>To avoid misunderstandings, this kind of test cases are named structural test cases and their characteristic is also different. Instead of verifying requirements, they rather \u201cstress\u201d the system-under-test by varying inputs and calibration parameters. Usually, these test cases are short and they take all signals in all steps into account. There are no \u201cDon\u2019t cares\u201d.\u00a0<\/p><p>But isn\u2019t this a self-fulfilling prophecy if these test cases are derived from the system-under-test and then executed on the system-under-test again? This is a valid question!<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-da6f93a elementor-widget elementor-widget-heading\" data-id=\"da6f93a\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Stimuli vector generation<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fa217fc elementor-widget elementor-widget-text-editor\" data-id=\"fa217fc\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Deriving structural test cases is a two-step process. At first, the (we call it) engines generate stimuli vectors. Stimuli vectors only contain input data. This means data for each input signal and each calibration parameter. They do not contain any information about outputs and internal measurement points. So, these stimuli vectors only describe how to reach a certain coverage goal.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p><p>Therefore, it does not matter from a general point of view if the stimuli vectors are derived from the model or from the code in a model-based development environment. If we look a bit deeper in this topic, there are several good reasons to consider the code as the source but to understand the general approach this does not make a difference.<\/p><p>The first benefit of these generated stimuli vectors is, that they may already point out some structural problems in the model or code that are related to the robustness of the system-under-test like overflows, covered division-by-zeros, values out-of-range or values in invalid value ranges, etc.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7303e71 elementor-widget elementor-widget-heading\" data-id=\"7303e71\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Back-to-Back comparison<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-0785e7e elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"0785e7e\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-910ca0c\" data-id=\"910ca0c\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-cb83936 elementor-widget elementor-widget-image\" data-id=\"cb83936\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"800\" height=\"535\" src=\"https:\/\/www.btc-embedded.com\/wp-content\/uploads\/2022\/05\/Blog_structural-test-cases_Tab1.png\" class=\"attachment-large size-large wp-image-8099\" alt=\"Difference of Functional and Structural Test Cases - Examples for use cases with structural test cases\" srcset=\"https:\/\/www.btc-embedded.com\/wp-content\/uploads\/2022\/05\/Blog_structural-test-cases_Tab1.png 1659w, https:\/\/www.btc-embedded.com\/wp-content\/uploads\/2022\/05\/Blog_structural-test-cases_Tab1-768x513.png 768w, https:\/\/www.btc-embedded.com\/wp-content\/uploads\/2022\/05\/Blog_structural-test-cases_Tab1-1536x1027.png 1536w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">additional use cases for Back-to-Back comparisons<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-2951757\" data-id=\"2951757\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-c5d70d0 elementor-widget elementor-widget-text-editor\" data-id=\"c5d70d0\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>For the second step, to derive structural test cases from the stimuli vectors, the tester decides, what should be the source implementation to derive the output behavior from. In model-based development, this is usually the model. Therefore, all generated stimuli vectors are executed on the model and the outputs coming from the simulation are recorded. Both, the stimuli part and the recorded output behavior from the simulation together result in a structural test case.\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-79c29f9 elementor-widget elementor-widget-text-editor\" data-id=\"79c29f9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>These structural test cases can now be executed again on the code to verify if the code also behaves structurally the same as the model. With other words, it verifies, if the model is translated correctly into code. The most common issues that can be observed are scaling differences, overflows or even compiler differences that all might lead to different behavior between model and code. Therefore, the Back-to-Back Test is highly recommended by the\u00a0<a href=\"https:\/\/www.btc-embedded.com\/use_cases\/iso-26262\/\" target=\"_blank\" rel=\"noopener\">ISO 26262<\/a><\/p><p>Since this approach relies on the model or code and the selected coverage goals, it does not need additional input or interaction from the tester. Therefore, this test approach can be fully automized and applied to a continues integration environment of the development and testing process.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cf6fff1 elementor-widget elementor-widget-heading\" data-id=\"cf6fff1\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">What structural test cases are not designed for?\n<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ef2476b elementor-widget elementor-widget-text-editor\" data-id=\"ef2476b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Since the automatic generation of structural test cases is a comfortable approach this also raises the question, if this generated test cases might randomly fit a requirement. Even though this might theoretically be possible and even that there are white papers theoretically talking about this approach, this will not be possible with almost absolute certainty.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p><p>But let\u2019s assume for a moment that some of the generated structural test cases fit a requirement. This means that the tester has to manually review all generated test cases and check if one of them fits one of the requirements. Since the model or code could still contain failures, they might be undiscovered by this approach.<\/p><p>In addition, the effort and complexity of this task will obviously increase exponentially with an increasing number of requirements and generated structural test cases. Once this is done the tester still has to write additional functional test cases for the not yet covered requirements. Finally, from the effort and complexity point of view, this approach is not applicable in a real test workflow.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9a9f5a0 elementor-widget elementor-widget-heading\" data-id=\"9a9f5a0\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Conclusion<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-be1858c elementor-widget elementor-widget-text-editor\" data-id=\"be1858c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Even though there is are huge differences of functional and structural test cases, so the automatically generated structural test cases and manual written functional test cases, they have their eligibility. They are an effective complement to the functional testing that, based on its systematic approach, discovers structural issues in and between model and code. We also learned that it is not a suitable approach to try to map automatically generated structural test cases to requirements.<\/p><p>Transferred to a book, the functional test cases check if the story is consistent and correct. Whereas the structural test cases have a look at the grammar and check if it is correctly translated into a different language. Finally, applying automatic structural test case generation to the test workflow will increase the test depth and robustness of the system-under-test.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>When it comes to unit testing in automotive industries, [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":9062,"comment_status":"open","ping_status":"closed","sticky":false,"template":"elementor_theme","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[49],"product":[],"use_cases":[],"class_list":["post-4280","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-model-based-development"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/posts\/4280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/comments?post=4280"}],"version-history":[{"count":0,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/posts\/4280\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/media\/9062"}],"wp:attachment":[{"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/media?parent=4280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/categories?post=4280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/tags?post=4280"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/product?post=4280"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.btc-embedded.com\/zh-hans\/wp-json\/wp\/v2\/use_cases?post=4280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}