{"id":228,"date":"2019-09-15T10:02:03","date_gmt":"2019-09-15T08:02:03","guid":{"rendered":"https:\/\/demo.themegrill.com\/colormag-business-magazine\/?p=228"},"modified":"2019-09-15T21:33:38","modified_gmt":"2019-09-15T19:33:38","slug":"how-to-pay-taxes-and-dont-overpay-tips-and-tricks","status":"publish","type":"post","link":"https:\/\/dufajn.pl\/?p=228","title":{"rendered":"Why we are using variables in test cases?"},"content":{"rendered":"<p><span data-preserver-spaces=\"true\">In case your salary is correlated with the number of created test cases or executed test steps please don&#8217;t read further. But if you want to know a bit more about variables in test cases and why I use them, read more.<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">Variables are an easy and important part of each test case. Imagine that you have a test objective to check that you can log in to the system using different user roles. Let&#8217;s assume for now that each role uses a similar login form. Of course you can prepare a nice number of similar-looking test cases but that&#8217;s only a waste of resources. Each test case should have been written in a way that corresponds to his test objective. Checking that the user can log in will be our main goal. But also we want to make this scenario as much reusable as possible.<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">Example test case steps (first part is step description, while second expected step result):<\/span><\/p>\n<ul>\n<li><span data-preserver-spaces=\"true\">Enter login name &#8211; Field name is populated with data<\/span><\/li>\n<li><span data-preserver-spaces=\"true\">Populate password field &#8211; Password is not blank<\/span><\/li>\n<li><span data-preserver-spaces=\"true\">Click on Login button &#8211; Button redirects to main page<\/span><\/li>\n<li><span data-preserver-spaces=\"true\">Check that user is logged as &#8220;role_name&#8221; &#8211; User &#8220;role_name&#8221; is logged<\/span><\/li>\n<\/ul>\n<p><span data-preserver-spaces=\"true\">In that above example, we have only one variable called &#8220;role_name&#8221;. In two different test configurations, we can use that variable and assign to her two different values. In our case &#8220;Admin&#8221; and &#8220;User&#8221;.<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">While test execution this variable will be called two times, giving different values each time. So for two test cases, the 4th step will look like this:<\/span><\/p>\n<ul>\n<li><span data-preserver-spaces=\"true\">Check that user is logged as &#8220;Admin&#8221; &#8211; User &#8220;Admin&#8221; is logged<\/span><\/li>\n<li><span data-preserver-spaces=\"true\">Check that user is logged as &#8220;User&#8221; &#8211; User &#8220;User&#8221; is logged<\/span><\/li>\n<\/ul>\n<p><span data-preserver-spaces=\"true\">Why we need to use variables in our test cases?<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">It&#8217;s faster to write one test case than multiple doing similar things. Also, it&#8217;s easier to maintain one version than multiple scenarios. Using a few variables in one test case gives more path covered in the execution phase, without any additional resources.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In case your salary is correlated with the number of created test cases or executed test steps please don&#8217;t read<\/p>\n","protected":false},"author":3,"featured_media":358,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"class_list":["post-228","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-testing"],"_links":{"self":[{"href":"https:\/\/dufajn.pl\/index.php?rest_route=\/wp\/v2\/posts\/228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dufajn.pl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dufajn.pl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dufajn.pl\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dufajn.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=228"}],"version-history":[{"count":2,"href":"https:\/\/dufajn.pl\/index.php?rest_route=\/wp\/v2\/posts\/228\/revisions"}],"predecessor-version":[{"id":361,"href":"https:\/\/dufajn.pl\/index.php?rest_route=\/wp\/v2\/posts\/228\/revisions\/361"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dufajn.pl\/index.php?rest_route=\/wp\/v2\/media\/358"}],"wp:attachment":[{"href":"https:\/\/dufajn.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dufajn.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dufajn.pl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}