{"id":229,"date":"2014-04-29T05:18:36","date_gmt":"2014-04-29T09:18:36","guid":{"rendered":"http:\/\/qxf2.com\/blog\/?p=229"},"modified":"2014-05-03T10:38:30","modified_gmt":"2014-05-03T14:38:30","slug":"a-simple-test-runner-for-windows","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/a-simple-test-runner-for-windows\/","title":{"rendered":"A simple test runner for Windows"},"content":{"rendered":"<p><strong>Problem:<\/strong> Developing a reliable test runner for your automation takes time. At <a href=\"http:\/\/www.qxf2.com\">Qxf2<\/a>, we would rather spend our time improving the quality of the tests and making automated checks more robust. This post will show you a quick way to develop a test runner on Windows.<\/p>\n<hr>\n<p>Testing teams usually have many automated test scripts that execute one after the other. A test runner executes the tests you want one after the other. Here is perhaps the quickest way to do so on Windows:<br \/>\n1. Gather your test scripts<br \/>\n2. Create a batch script<br \/>\n3. Create a scheduled task <\/p>\n<p>For the purposes of this example, we&#8217;ll use two dummy scripts that take in command line arguments and execute them. <\/p>\n<p><strong>STEP 1: Gather your scripts<\/strong><br \/>\nAt Qxf2, Python is our language of choice. For this example, I&#8217;ve written up two throwaway script that will take a string as an input parameter and print out the string 10 times over 10 seconds.<br \/>\n<a href=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/script.jpg\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/script.jpg\" alt=\"script\" width=\"966\" height=\"682\" class=\"aligncenter size-full wp-image-230\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/script.jpg 966w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/script-300x211.jpg 300w\" sizes=\"auto, (max-width: 966px) 100vw, 966px\" \/><\/a><\/p>\n<p><strong>STEP 2: Create a batch script<\/strong><br \/>\nCreate a batch script that looks like below. For batch scripting newbies:<br \/>\n&#8211; %1 is used for the first command line argument you pass to the batch script<br \/>\n&#8211; in this case we will pass the directory where our test scripts are located<br \/>\n&#8211; :: is used for comments<br \/>\n<a href=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/batch_script1.jpg\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/batch_script1.jpg\" alt=\"batch_script\" width=\"964\" height=\"326\" class=\"aligncenter size-full wp-image-232\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/batch_script1.jpg 964w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/batch_script1-300x101.jpg 300w\" sizes=\"auto, (max-width: 964px) 100vw, 964px\" \/><\/a><\/p>\n<p>You can test your batch script by opening up a command prompt, changing your directory to where the batch script is located and running it. If you are using the example provided here, you would run something like:<br \/>\n>> <strong>sample_bat<\/strong>  path_to_the_python_test_scripts<\/p>\n<p><strong>STEP 3: Create a scheduled task<\/strong><br \/>\nScheduled tasks on Windows are like cron jobs on Unix based systems. There are many <a href=\"http:\/\/windows.microsoft.com\/en-in\/windows\/schedule-task#1TC=windows-7\">good tutorials<\/a> on creating scheduled tasks on Windows. The summary is that you create a basic task and schedule it to run with the frequency that you like. Just make sure that your task Action is configured to look like the screenshot below.<br \/>\n<a href=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/scheduled_task.jpg\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/scheduled_task.jpg\" alt=\"scheduled_task\" width=\"643\" height=\"484\" class=\"aligncenter size-full wp-image-233\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/scheduled_task.jpg 643w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/04\/scheduled_task-300x225.jpg 300w\" sizes=\"auto, (max-width: 643px) 100vw, 643px\" \/><\/a><\/p>\n<p>You can test your scheduled task by right clicking on it in the task scheduler and selecting &#8216;Run&#8217;. <\/p>\n<p>As and when you develop new tests, you can add them to the batch script. There you have it &#8211; a lightweight test runner on Windows. <\/p>\n<hr>\n<p>As with all technical solutions, the use of this technique depends on your current context.<br \/>\nSome situations to use this technique are:<br \/>\n&#8211; in early stages of introducing automation in your company<br \/>\n&#8211; you want to get nightly automation going as soon as possible<br \/>\n&#8211; in ambitious, tight schedules that leave little time for developing QA infrastructure<br \/>\n&#8211; the project demands a lightweight solution<\/p>\n<p>Some situations where you should NOT to use this technique?<br \/>\n&#8211; you have the budget to invest on QA infrastructure<br \/>\n&#8211; the complexity of your automation suite requires a heavyweight solution<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem: Developing a reliable test runner for your automation takes time. At Qxf2, we would rather spend our time improving the quality of the tests and making automated checks more robust. This post will show you a quick way to develop a test runner on Windows. Testing teams usually have many automated test scripts that execute one after the other. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,18],"tags":[21,20,22],"class_list":["post-229","post","type-post","status-publish","format-standard","hentry","category-how-to","category-python","tag-batch-scripts","tag-task-scheduler","tag-test-runner"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=229"}],"version-history":[{"count":10,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/229\/revisions"}],"predecessor-version":[{"id":243,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/229\/revisions\/243"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}