{"id":804,"date":"2023-01-25T18:27:51","date_gmt":"2023-01-25T17:27:51","guid":{"rendered":"http:\/\/blog.ansuz.nl\/?p=804"},"modified":"2023-01-25T18:27:52","modified_gmt":"2023-01-25T17:27:52","slug":"characterization-testing","status":"publish","type":"post","link":"http:\/\/blog.ansuz.nl\/index.php\/2023\/01\/25\/characterization-testing\/","title":{"rendered":"Characterization Testing"},"content":{"rendered":"\n<p>A nice way to help you refactor legacy code is to use &#8220;Characterization Testing&#8221; or &#8220;Golden Master testing&#8221;. These approach provide a quick way to get cover legacy code with _some_ tests. There is a big catch though:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Unlike regression tests, to which they are very similar, characterization tests do not verify the correct behavior of the code, which can be impossible to determine. Instead they verify the behavior that was observed when they were written.<\/p><cite><a href=\"https:\/\/en.wikipedia.org\/wiki\/Characterization_test\">https:\/\/en.wikipedia.org\/wiki\/Characterization_test<\/a><\/cite><\/blockquote>\n\n\n\n<p>You can use a tool like &#8220;Approval tests&#8221; to quickly set up &#8220;Characterization Testing&#8221;. Emily Bache has a nice introduction video about working with &#8220;Approval tests&#8221;.<\/p>\n\n\n\n<p>After you&#8217;ve covered the legacy code using &#8220;Characterization Testing&#8221;, you can start refactoring the legacy code. At this point, don&#8217;t forget to add unit tests for the new code you&#8217;re writing.<\/p>\n\n\n\n<p>For more info have a look at:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Characterization_test\">https:\/\/en.wikipedia.org\/wiki\/Characterization_test<\/a><\/li><li><a href=\"https:\/\/approvaltests.com\/\">https:\/\/approvaltests.com\/<\/a><\/li><li><a href=\"https:\/\/youtu.be\/zyM2Ep28ED8\">https:\/\/youtu.be\/zyM2Ep28ED8<\/a><\/li><\/ul>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>A nice way to help you refactor legacy code is to use &#8220;Characterization Testing&#8221; or &#8220;Golden Master testing&#8221;. These approach provide a quick way to get cover legacy code with _some_ tests. There is a big catch though: Unlike regression &hellip; <a href=\"http:\/\/blog.ansuz.nl\/index.php\/2023\/01\/25\/characterization-testing\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[170,160],"tags":[],"class_list":["post-804","post","type-post","status-publish","format-standard","hentry","category-general-programming","category-testing"],"_links":{"self":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/comments?post=804"}],"version-history":[{"count":1,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/804\/revisions"}],"predecessor-version":[{"id":805,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/804\/revisions\/805"}],"wp:attachment":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/media?parent=804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/categories?post=804"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/tags?post=804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}