{"id":191,"date":"2024-10-17T23:02:25","date_gmt":"2024-10-18T06:02:25","guid":{"rendered":"http:\/\/flenniken.net\/blog\/?p=191"},"modified":"2024-10-19T15:29:30","modified_gmt":"2024-10-19T22:29:30","slug":"stfrunner","status":"publish","type":"post","link":"https:\/\/flenniken.net\/blog\/stfrunner\/","title":{"rendered":"StfRunner"},"content":{"rendered":"\n<p>The stfRunner command is used for running statictea system tests.<br><br>StfRunner executes a stf test file which tests a feature. A stf file contains instructions for creating files, running files and comparing files.<br><br>A normal test creates all the input files, runs statictea then compares the outputs to the expected values. <br><br>Although stfRunner was written to test statictea, you can use it to test any command line program. <br><br>What\u2019s cool about it:<br><br>* you specify each test in one file<br>* a test with its documentation looks good in a markdown reader<br>* the test file format is simple<br>* you can test standard out, standard error, the error code as well as files<br><br>Below is the hello world statictea readme example. The test creates four files \u201ccmd.sh\u201d, \u201chello.json\u201d, \u201chello.html\u201d and \u201cstdout.expected\u201d. It then runs the cmd.sh file which creates two output files: \u201cstdout\u201d and \u201cstderr\u201d. The final steps compare the output files with the expected files. <br><br><code>stf file, version 0.1.0<br><br># Hello World<br><br>Readme Hello World example.<br><br>### File cmd.sh command<br><br>~~~<br>$statictea \\<br>  -s hello.json \\<br>  -t hello.html \\<br>  >stdout 2>stderr<br>~~~<br><br>### File hello.html<br><br>~~~<br>hello {s.name}<br>~~~<br><br>### File hello.json<br><br>~~~<br>{\"name\": \"world\"}<br>~~~<br><br>### File stdout.expected<br><br>~~~<br>hello world<br>~~~<br><br>### Expected stdout == stdout.expected<br>### Expected stderr == empty<\/code><br> <br>In this example, six files where created. Using some other test method, it would be hard to manage all these files when you have a lot of tests. <br><br>Since the test file is a markdown file, you can create easy to read tests and associated embedded documentation and it looks good in a markdown reader. You can see what hello world it looks like viewed with github\u2019s viewer:<br><br>* <a href=\"https:\/\/github.com\/flenniken\/statictea\/blob\/master\/testfiles\/hello.stf.md\">hello.stf.md<\/a><br><br>Here are all the statictea system tests:<br><br>* <a href=\"https:\/\/github.com\/flenniken\/statictea\/blob\/master\/testfiles\/stf-index.md\">statictea stf tests<\/a><br><br>I\u2019m planning to spin out stfRunner into its own standalone github project.<\/p>\n\n\n\n<p>The letters STF stand for \u201cSingle Test File\u201d or my name STeve Flenniken. <br><br>I\u2019m considering changing its name to tea-runner. You can think of it as t-runner for test-runner, stf-runner, or maybe rum-runner or beer-run.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The stfRunner command is used for running statictea system tests. StfRunner executes a stf test file which tests a feature. A stf file contains instructions for creating files, running files and comparing files. A normal test creates all the input &hellip; <a href=\"https:\/\/flenniken.net\/blog\/stfrunner\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-191","post","type-post","status-publish","format-standard","hentry","category-statictea"],"_links":{"self":[{"href":"https:\/\/flenniken.net\/blog\/wp-json\/wp\/v2\/posts\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/flenniken.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flenniken.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flenniken.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/flenniken.net\/blog\/wp-json\/wp\/v2\/comments?post=191"}],"version-history":[{"count":11,"href":"https:\/\/flenniken.net\/blog\/wp-json\/wp\/v2\/posts\/191\/revisions"}],"predecessor-version":[{"id":224,"href":"https:\/\/flenniken.net\/blog\/wp-json\/wp\/v2\/posts\/191\/revisions\/224"}],"wp:attachment":[{"href":"https:\/\/flenniken.net\/blog\/wp-json\/wp\/v2\/media?parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flenniken.net\/blog\/wp-json\/wp\/v2\/categories?post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flenniken.net\/blog\/wp-json\/wp\/v2\/tags?post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}