{"id":968,"date":"2011-11-08T08:27:53","date_gmt":"2011-11-08T13:27:53","guid":{"rendered":"http:\/\/mainlinetest.com\/?p=968"},"modified":"2011-11-08T08:39:18","modified_gmt":"2011-11-08T13:39:18","slug":"sequence-call-step-type-vs-sequence-adapter","status":"publish","type":"post","link":"https:\/\/mainlinetest.com\/?p=968","title":{"rendered":"Sequence Call Step Type vs. Sequence Adapter"},"content":{"rendered":"<p>While taking the Certified TestStand Developer exam, I noticed there were a couple of questions revolving around the Sequence Adapter.\u00a0 The Sequence Adapter is not commonly used due to the fact that TestStand comes with the default Sequence Call step type.\u00a0 However, I wanted to use this post to introduce the use of the Sequence Adapter in lieu of the Sequence Call step type as a TestStand best practice.\u00a0 To demonstrate this, the first thing I am going to do is create a new sequence in my script and name it \u2018SubSequence\u2019.\u00a0 Inside \u2018SubSequence\u2019 I will simply insert a Wait statement with a duration of 5 seconds.\u00a0 The figure below shows my sequence thus far.<\/p>\n<p><a href=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image_thumb.png\" border=\"0\" alt=\"image\" width=\"520\" height=\"181\" \/><\/a><\/p>\n<p>Back in the MainSequence I will now insert a call to \u2018SubSequence\u2019.\u00a0 For the first part I will use the Sequence Call step type and name it \u2018SequenceCallViaStepType\u2019.\u00a0 The figure below shows my new sequence.<\/p>\n<p><a href=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image_thumb1.png\" border=\"0\" alt=\"image\" width=\"520\" height=\"169\" \/><\/a><\/p>\n<p>Now I am going to put a breakpoint at the end of the sequence and execute the script.\u00a0 Observe in the figure below how the Step.Result.Status value is set to \u201cPassed\u201d.<\/p>\n<p><a href=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image_thumb2.png\" border=\"0\" alt=\"image\" width=\"520\" height=\"126\" \/><\/a><\/p>\n<p>In fact, if I go to the Properties of the step and view the Expressions, you will see the Status Expression is set to the following:<\/p>\n<p><em>(Step.Result.Status == &#8220;Done&#8221; &amp;&amp; (Step.TS.SData.ThreadOpt == 0 || Step.TS.SData.ThreadOpt == 3)) ? &#8220;Passed&#8221; : Step.Result.Status<\/em><\/p>\n<p>As you can see, TestStand actually overrides the status to \u201cPassed\u201d if the sequence returns \u201cDone\u201d.\u00a0 See the figure below for the screenshot of this.<\/p>\n<p><a href=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image3.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image_thumb3.png\" border=\"0\" alt=\"image\" width=\"520\" height=\"231\" \/><\/a><\/p>\n<p>Next I am going to modify my script such that I insert an Action step type but this time I am going to use the Sequence Adapter.\u00a0 The figure below shows this setting.<\/p>\n<p><a href=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image4.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image_thumb4.png\" border=\"0\" alt=\"image\" width=\"409\" height=\"277\" \/><\/a><\/p>\n<p>Back in MainSequence I will have the new Action step also call \u2018SubSequence\u2019.\u00a0 This time I have named the step \u2018SequenceCallViaAdapter\u2019.\u00a0 See the figure below for my new sequence.\u00a0 Observe how the step description also shows the second step being an Action step type.<\/p>\n<p><a href=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image5.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image_thumb5.png\" border=\"0\" alt=\"image\" width=\"520\" height=\"164\" \/><\/a><\/p>\n<p>Now, with the breakpoint in place at the end of the script, I am going to execute the sequence one last time.\u00a0 Observe in the figure below how the Step.Result.Status value is now set to \u201cDone\u201d for the new step.<\/p>\n<p><a href=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image6.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image_thumb6.png\" border=\"0\" alt=\"image\" width=\"520\" height=\"126\" \/><\/a><\/p>\n<p>This is a big deal in terms of developing a clean looking script.\u00a0 You see, the only other step types that return a status of \u201cPassed\u201d besides the Sequence Call step type are the Test step types.\u00a0 Now with the introduction of the Sequence Adapter, you can develop a script in which the only step types that return a \u201cPassed\u201d status are the Tests.\u00a0 Sequence Calls are functions and should rarely be used to determine Pass\/Fail criteria.\u00a0 A good function should return the necessary data to a Test step type to determine a pass or failure but the Sequence Call itself should not decide.\u00a0 A good function should also be developed with the purpose of being used more than once and therefore separation amongst the function and the Test is better for code reuse.<\/p>\n<p>Lets look at the final report of my script in the figure below.<\/p>\n<p><a href=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image7.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/mainlinetest.com\/wp-content\/uploads\/2011\/11\/image_thumb7.png\" border=\"0\" alt=\"image\" width=\"420\" height=\"271\" \/><\/a><\/p>\n<p>Imagine if this report were full of Test step types.\u00a0 A quick glance at the report would make it hard for the end user to know which steps were Tests and which were Sequence Calls.\u00a0 One should be able to look at the final report and know which steps are the true Pass\/Fail criteria.\u00a0 Especially if the Pass\/Fail criteria are being traced to requirements.\u00a0 In conclusion, the Sequence Adapter is a powerful alternative to the Sequence Call step type and is something that should be adopted in your scripting best practices.\u00a0 It is understandable why the folks at NI would want those seeking certification to be tested on it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While taking the Certified TestStand Developer exam, I noticed there were a couple of questions revolving around the Sequence Adapter.\u00a0 The Sequence Adapter is not commonly used due to the fact that TestStand comes with the default Sequence Call step type.\u00a0 However, I wanted to use this post to introduce the use of the Sequence&nbsp;<a href=\"https:\/\/mainlinetest.com\/?p=968\" class=\"read-more\">Continue Reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":741,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[35,33,34,31,32,23],"class_list":["post-968","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-best-practices","tag-certified-teststand-developer","tag-certified-teststand-developer-exam","tag-sequence-adapter","tag-sequence-call","tag-teststand","cat-1-id"],"_links":{"self":[{"href":"https:\/\/mainlinetest.com\/index.php?rest_route=\/wp\/v2\/posts\/968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mainlinetest.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mainlinetest.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mainlinetest.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mainlinetest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=968"}],"version-history":[{"count":4,"href":"https:\/\/mainlinetest.com\/index.php?rest_route=\/wp\/v2\/posts\/968\/revisions"}],"predecessor-version":[{"id":972,"href":"https:\/\/mainlinetest.com\/index.php?rest_route=\/wp\/v2\/posts\/968\/revisions\/972"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mainlinetest.com\/index.php?rest_route=\/wp\/v2\/media\/741"}],"wp:attachment":[{"href":"https:\/\/mainlinetest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mainlinetest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mainlinetest.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}