{"id":1053,"date":"2013-05-05T20:58:03","date_gmt":"2013-05-06T02:58:03","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=1053"},"modified":"2014-09-13T08:39:07","modified_gmt":"2014-09-13T14:39:07","slug":"testing-with-pentaho-kettle-the-test-suite-runner","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/1053","title":{"rendered":"Testing with Pentaho Kettle &#8211; the test suite runner"},"content":{"rendered":"<p>After we can run one test case, the next step is to run a number of test cases at one time.  <\/p>\n<p>Heads up, this article is part of a series on testing ETL transformations written with Pentaho Kettle.  Previous posts covered:<\/p>\n<ul>\n<li>The <a href=\"\/wordpress\/archives\/995\">benefits of automated testing for ETL jobs<\/a><\/li>\n<li><a href=\"\/wordpress\/archives\/1031\">what parts of ETL processes to test<\/a><\/li>\n<li><a href=\"\/wordpress\/archives\/1026\">current options and frameworks for testing Kettle<\/a><\/li>\n<li><a href=\"\/wordpress\/archives\/1010\">writing testable business logic<\/a><\/li>\n<li><a href=\"\/wordpress\/archives\/1033\">running one test using TestCaseRunner<\/a><\/li>\n<\/ul>\n<p>Running multiple tests allows us to exercise logic in transformations by adjusting the input and expected output files.  This allows you to test a number of edge cases easily.<\/p>\n<p><a href=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testsuite-runner-75.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1054\" alt=\"pentaho-testsuite-runner-75\" src=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testsuite-runner-75-300x168.png\" width=\"300\" height=\"168\" srcset=\"http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testsuite-runner-75-300x168.png 300w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testsuite-runner-75-1024x575.png 1024w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testsuite-runner-75.png 1025w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>First, we need to build a CSV to drive the test cases.\u00a0 Here is the <a href=\"https:\/\/github.com\/mooreds\/pentaho-kettle-testing\/blob\/master\/src\/test\/resources\/tests.csv\">test list file<\/a>.\u00a0 This file is read by a transformation that loads the rows and passes them to the next job entry.\u00a0 The next job entry is the <a href=\"\/wordpress\/archives\/1033\">TestCaseRunner<\/a> we saw in the last post, once for each line in the csv file.\u00a0 As you can see below, we filter any rows that start with a #.\u00a0 This behavior helps immensely when you are developing a new test, and don&#8217;t want to run all the other tests in your suite (typically because of how long it can take).<\/p>\n<p><a href=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-load-tests-from-file-75.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1055\" alt=\"pentaho-load-tests-from-file-75\" src=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-load-tests-from-file-75-300x168.png\" width=\"300\" height=\"168\" srcset=\"http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-load-tests-from-file-75-300x168.png 300w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-load-tests-from-file-75-1024x575.png 1024w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-load-tests-from-file-75.png 1025w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>In order to drive each test case from the rows output by the Load Tests From File transformation, we need to modify the job settings of the TestCaseRunner.\u00a0 Below we&#8217;ve checked the &#8216;copy previous results to parameters&#8217; checkbox which takes the results output from the tests.csv file loaded by the previous transformations and uses them as parameters for the TestCaseRunner job.\u00a0 We also checked the &#8216;execute for every input row&#8217; checkbox which will execute the testcase once for each row.  This lets us add a new test by adding a line to the file.<\/p>\n<p><a href=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testsuite-runner-drive-testcase-75.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1057\" alt=\"pentaho-testsuite-runner-drive-testcase-75\" src=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testsuite-runner-drive-testcase-75-300x168.png\" width=\"300\" height=\"168\" srcset=\"http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testsuite-runner-drive-testcase-75-300x168.png 300w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testsuite-runner-drive-testcase-75-1024x575.png 1024w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testsuite-runner-drive-testcase-75.png 1025w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Obviously, taking these parameters requires modifications to the TestCaseRunner job.\u00a0 Rather than have the input.file and expected.file variables hardcoded <a href=\"\/wordpress\/archives\/1033\">as we did previously<\/a>, we need to take them as parameters:<\/p>\n<p><a href=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testcase-runner-modified-setvars-75.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1056\" alt=\"pentaho-testcase-runner-modified-setvars-75\" src=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testcase-runner-modified-setvars-75-300x168.png\" width=\"300\" height=\"168\" srcset=\"http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testcase-runner-modified-setvars-75-300x168.png 300w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testcase-runner-modified-setvars-75-1024x575.png 1024w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testcase-runner-modified-setvars-75.png 1025w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>We also pass a test.name parameter, so that we can distinguish between tests that fail and those that succeed.\u00a0 We also create a directory for test results that we don&#8217;t delete after the test suite is run, and output a success or failure marker file after a test is run.<\/p>\n<p><a href=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testcase-runner-modified-for-suite-751.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1067\" alt=\"pentaho-testcase-runner-modified-for-suite-75\" src=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testcase-runner-modified-for-suite-751-300x168.png\" width=\"300\" height=\"168\" srcset=\"http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testcase-runner-modified-for-suite-751-300x168.png 300w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testcase-runner-modified-for-suite-751-1024x575.png 1024w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-testcase-runner-modified-for-suite-751.png 1025w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>You can run the TestSuiteRunner job in Spoon by hitting the play button or f9.<\/p>\n<p>As a reminder, I&#8217;ll be publishing another installment of this tutorial in a couple of days&#8211;we&#8217;ll cover how to add new logic.\u00a0 But if you can&#8217;t wait, the full code for the <a href=\"https:\/\/github.com\/mooreds\/pentaho-kettle-testing\/\">Pentaho ETL Testing Example<\/a> is on github.<\/p>\n<p>Signup for my <a href=\"http:\/\/eepurl.com\/x2Biz\">infrequent emails about pentaho testing<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After we can run one test case, the next step is to run a number of test cases at one time. Heads up, this article is part of a series [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63,58],"tags":[],"class_list":["post-1053","post","type-post","status-publish","format-standard","hentry","category-pentaho-data-integration","category-testing"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1053"}],"version-history":[{"count":10,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1053\/revisions"}],"predecessor-version":[{"id":1748,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1053\/revisions\/1748"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}