{"id":2076,"date":"2019-12-11T17:05:35","date_gmt":"2019-12-11T16:05:35","guid":{"rendered":"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/"},"modified":"2021-12-23T14:12:19","modified_gmt":"2021-12-23T13:12:19","slug":"how-to-challenge-your-code-with-property-based-testing-part-1","status":"publish","type":"post","link":"https:\/\/www.codemotion.com\/magazine\/devops\/qa-testing\/how-to-challenge-your-code-with-property-based-testing-part-1\/","title":{"rendered":"How to Challenge Your Code with Property-Based Testing &#8211; Part 1"},"content":{"rendered":"<p>What does Property-Based Testing mean for developers? Well, a debate persists in <span id=\"urn:batch-analysis-8a34eae6-0715-4c5c-ab85-27947661b8ed\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/cogito_software\">software<\/span> as to the exact nature, division and scope of &#8220;testing&#8221; activities. We need to check that a particular software component produces the expected output with the expected inputs provided. Yet we also need to expose the behaviour of this component against unforeseen or unpredictable inputs.<\/p>\n<p>The first activity is usually referred to as &#8220;checking&#8221;, while the second is called &#8220;exploring&#8221; and both contribute to defining the software components as &#8220;tested&#8221;.<\/p>\n<p>The boundary that divides these two different activities is often linked to the level of <span id=\"urn:batch-analysis-e37d1215-5dfe-45b8-b303-734a495fd046\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/knowledge\">knowledge<\/span> of the component being examined. However, we must be very careful not to confuse the <span id=\"urn:batch-analysis-1d2bf4cb-7fa9-4cda-89d8-083a81e684a2\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/knowledge\">knowledge<\/span> of the issue under analysis with the illusion of <span id=\"urn:batch-analysis-573e18c6-5a87-4edc-97d0-37491beec803\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/knowledge\">knowledge<\/span>.<\/p>\n<figure class=\"image regular \"><picture><source srcset=\"https:\/\/codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/Copiadibaas-part-01-image-01_dc429d62f11b33d8bf5b8b4374b97a6a_800.png 1x, https:\/\/images.storychief.com\/account_16344\/Copiadibaas-part-01-image-01_dc429d62f11b33d8bf5b8b4374b97a6a_1600.png 2x\" media=\"(max-width: 768px)\" \/><source srcset=\"https:\/\/codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/Copiadibaas-part-01-image-01_dc429d62f11b33d8bf5b8b4374b97a6a_800.png 1x, https:\/\/images.storychief.com\/account_16344\/Copiadibaas-part-01-image-01_dc429d62f11b33d8bf5b8b4374b97a6a_1600.png 2x\" media=\"(min-width: 769px)\" \/><img decoding=\"async\" src=\"https:\/\/codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/Copiadibaas-part-01-image-01_dc429d62f11b33d8bf5b8b4374b97a6a_800.png\" alt=\"the illusion of knowledge in property based testing \" \/><\/picture><figcaption>The illusion of <span id=\"urn:batch-analysis-b2d4638e-438d-4c0c-95ef-e7ab044a3ebf\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/knowledge\">knowledge<\/span><\/figcaption><\/figure>\n<h2 id=\"1co1t\">Introducing the Black Swan Theory<\/h2>\n<p>A common example of the negative effects of the illusion of <span id=\"urn:batch-analysis-151d66a7-efc6-49c4-8237-3027a21cad21\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/knowledge\">knowledge<\/span> is the so-called &#8220;black swan theory&#8221; introduced by Nassim Nicholas Taleb in 2007. In short, if it is assumed that all swans are white and that, therefore, black swans cannot exist, it means the existence of a single black swan can bring down the whole theory.<\/p>\n<p>In the field of testing, <strong>the illusion of <span id=\"urn:batch-analysis-ca7fd0c4-8864-4e0a-9ad7-eaac329af3f8\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/knowledge\">knowledge<\/span> is linked to the cognitive <span id=\"urn:batch-analysis-095fde0e-6ad5-4da4-8a14-c4ab1379d86a\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/bias\">bias<\/span><\/strong> that, want it or not, we apply both when we write code and when we design and structure the various tests and test cases necessary to confirm the functionality of the code itself.<\/p>\n<p><strong>Some types of automatic tests, such as unit tests, only allow confirmation of the behaviour<\/strong>. An example is the confirmation of the occurrence of a certain condition. What could happen unexpectedly in code like the following?<\/p>\n<p>&lt;script src=&#8221;https:\/\/gist.github.com\/elleuca\/267b5db40dd72c03234c5eb76b9835c5.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p>It is preferable to add the various limit cases of interest. However,\u00a0 the illusion of knowing the range within the price we will pass to the function will vary. This could lead to the <span id=\"urn:batch-analysis-f235b0b0-33c0-4887-8386-f79836a83f4f\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/belief\">belief<\/span> that it will never provide a value that can produce an unexpected result.<\/p>\n<p>Have you ever tried to use Shakespeare&#8217;s entire work in Japanese and Korean as an input to your method that takes a valid string as a parameter? It&#8217;s an impossible case, so why should we use it as input for a test?<\/p>\n<h2 id=\"6lenk\"><strong>Qualities of Good Testing<\/strong><\/h2>\n<p>What we could expect from good testing? At <a href=\"https:\/\/events.codemotion.com\/conferences\/rome\/2019\/\">Codemotion Rome 2019<\/a>, Kenny Baas and Jo\u00e3o Rosa shared their ideas about how testing should work to shift from just confirming to <span id=\"urn:batch-analysis-4fdc9e85-441f-4075-a2c5-a9585fdf21b4\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/learning\">learning<\/span>. When your software breaks, it is caused by at least one mistake. It happens, but <strong>you can leverage those mistakes to learn more about what you built<\/strong> or the actual context of the problem you are trying to solve.<\/p>\n<figure class=\"image regular \"><picture><source srcset=\"https:\/\/codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/Copiadibaas-part-01-image-02_fce8f43b10c0fb33d736f0afd21fb2f2_800.png 1x, https:\/\/images.storychief.com\/account_16344\/Copiadibaas-part-01-image-02_fce8f43b10c0fb33d736f0afd21fb2f2_1600.png 2x\" media=\"(max-width: 768px)\" \/><source srcset=\"https:\/\/codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/Copiadibaas-part-01-image-02_fce8f43b10c0fb33d736f0afd21fb2f2_800.png 1x, https:\/\/images.storychief.com\/account_16344\/Copiadibaas-part-01-image-02_fce8f43b10c0fb33d736f0afd21fb2f2_1600.png 2x\" media=\"(min-width: 769px)\" \/><img decoding=\"async\" src=\"https:\/\/codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/Copiadibaas-part-01-image-02_fce8f43b10c0fb33d736f0afd21fb2f2_800.png\" alt=\"Single abstraction examples in property based unit tests\" \/><\/picture><figcaption>Abstraction as Unit testing<\/figcaption><\/figure>\n<h2 id=\"3kji4\">Learn and Challenge Code Through Property Based Testing<\/h2>\n<p>If you want to learn more about the context, or the domain you are working on, your tests should describe and communicate what is happening. Domain-Driven Design can help you to write code that is based on the same language developers speak with each other and other domain experts. <strong>Tests should help you to document how your <span id=\"urn:batch-analysis-ad71efcc-86b3-4caf-ad68-6b3d67190439\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/cogito_software\">software<\/span> behaves<\/strong>, not assert that it can pass a pile of anonymous data points.<\/p>\n<p>To challenge the code you wrote, you need to move away from the comfort zone of known valid inputs and feed it unforeseen <span id=\"urn:batch-analysis-665f7f42-b389-4a87-97d5-29b2ef52115a\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/data\">data<\/span> that can disprove your illusion of safety. If you can do so, <strong><span id=\"urn:batch-analysis-1781ab6f-f26d-48ef-8990-58c5c38670d0\" class=\"textannotation disambiguated wl-no-link wl-other\" itemid=\"http:\/\/data.wordlift.io\/wl01770\/entity\/failure\">failures<\/span> in tests will reveal an actual problem in your system<\/strong>. If not, the tests will only assert that your system will work when it flows as expected.<\/p>\n<p>Such kind of testing is called <strong>\u201cproperty based testing\u201d and helps to introduce a degree of fuzziness in test inputs<\/strong>, allowing to move from single abstraction examples (a.k.a. unit tests) to an active scanning of system behaviour.<\/p>\n<p>In the next article of this series, we\u2019ll explore more about how to start building property based testing. Stay tuned&#8230;<\/p>\n<figure class=\"video regular \">\n<div class=\"embed-container\">\n<div style=\"max-width: 100%; position: relative; padding-top: 56.25%;\"><iframe loading=\"lazy\" style=\"position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;\" src=\"https:\/\/www.youtube.com\/embed\/WJeHEquk1pQ?feature=oembed\" width=\"480\" height=\"270\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\n<\/div>\n<\/figure>\n<p><!-- strchf script --><script>        if(window.strchfSettings === undefined) window.strchfSettings = {};    window.strchfSettings.stats = {url: \"https:\/\/codemotion.storychief.io\/how-to-challenge-your-code-with-property-based-testing-part-1?id=1859482483&type=2\",title: \"How to Challenge Your Code with Property-Based Testing - Part 1\",id: \"66543c6c-96d5-4792-a44b-49339654b7a1\"};            (function(d, s, id) {      var js, sjs = d.getElementsByTagName(s)[0];      if (d.getElementById(id)) {window.strchf.update(); return;}      js = d.createElement(s); js.id = id;      js.src = \"https:\/\/d37oebn0w9ir6a.cloudfront.net\/scripts\/v0\/strchf.js\";      js.async = true;      sjs.parentNode.insertBefore(js, sjs);    }(document, 'script', 'storychief-jssdk'))    <\/script><!-- End strchf script --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You need to challenge the code you write by moving away from the comfort zone of known valid inputs by feeding with unforeseen data that can disprove your safety illusions.<\/p>\n","protected":false},"author":30,"featured_media":2077,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","_uag_custom_page_level_css":"","_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[9885],"tags":[4,4359],"collections":[],"class_list":{"0":"post-2076","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-qa-testing","8":"tag-codemotion-rome","9":"tag-testing","10":"entry"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Property-Based Testing: How to Challenge Your Code (Part 1) - Codemotion<\/title>\n<meta name=\"description\" content=\"Part 1 on how devs can utilize property based testing to challenge the code they write for better outcomes.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Challenge Your Code with Property-Based Testing - Part 1\" \/>\n<meta property=\"og:description\" content=\"Part 1 on how devs can utilize property based testing to challenge the code they write for better outcomes.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/\" \/>\n<meta property=\"og:site_name\" content=\"Codemotion Magazine\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Codemotion.Italy\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-11T16:05:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-23T13:12:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1013\" \/>\n\t<meta property=\"og:image:height\" content=\"675\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Luca Ferretti\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CodemotionIT\" \/>\n<meta name=\"twitter:site\" content=\"@CodemotionIT\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Luca Ferretti\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.codemotion.com\/magazine\/devops\/qa-testing\/how-to-challenge-your-code-with-property-based-testing-part-1\/\"},\"author\":{\"name\":\"Luca Ferretti\",\"@id\":\"https:\/\/www.codemotion.com\/magazine\/#\/schema\/person\/00344cc4e23bb0758378ab701b57f1a1\"},\"headline\":\"How to Challenge Your Code with Property-Based Testing &#8211; Part 1\",\"datePublished\":\"2019-12-11T16:05:35+00:00\",\"dateModified\":\"2021-12-23T13:12:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.codemotion.com\/magazine\/devops\/qa-testing\/how-to-challenge-your-code-with-property-based-testing-part-1\/\"},\"wordCount\":677,\"publisher\":{\"@id\":\"https:\/\/www.codemotion.com\/magazine\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg\",\"keywords\":[\"Codemotion Rome\",\"Testing\"],\"articleSection\":[\"QA\/Testing\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.codemotion.com\/magazine\/devops\/qa-testing\/how-to-challenge-your-code-with-property-based-testing-part-1\/\",\"url\":\"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/\",\"name\":\"Property-Based Testing: How to Challenge Your Code (Part 1) - Codemotion\",\"isPartOf\":{\"@id\":\"https:\/\/www.codemotion.com\/magazine\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg\",\"datePublished\":\"2019-12-11T16:05:35+00:00\",\"dateModified\":\"2021-12-23T13:12:19+00:00\",\"description\":\"Part 1 on how devs can utilize property based testing to challenge the code they write for better outcomes.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#primaryimage\",\"url\":\"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg\",\"contentUrl\":\"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg\",\"width\":1013,\"height\":675,\"caption\":\"How to Challenge Your Code with Property-Based Testing - Part 1\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.codemotion.com\/magazine\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DevOps\",\"item\":\"https:\/\/www.codemotion.com\/magazine\/devops\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"QA\/Testing\",\"item\":\"https:\/\/www.codemotion.com\/magazine\/devops\/qa-testing\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How to Challenge Your Code with Property-Based Testing &#8211; Part 1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.codemotion.com\/magazine\/#website\",\"url\":\"https:\/\/www.codemotion.com\/magazine\/\",\"name\":\"Codemotion Magazine\",\"description\":\"We code the future. Together\",\"publisher\":{\"@id\":\"https:\/\/www.codemotion.com\/magazine\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.codemotion.com\/magazine\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.codemotion.com\/magazine\/#organization\",\"name\":\"Codemotion\",\"url\":\"https:\/\/www.codemotion.com\/magazine\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.codemotion.com\/magazine\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/11\/codemotionlogo.png\",\"contentUrl\":\"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/11\/codemotionlogo.png\",\"width\":225,\"height\":225,\"caption\":\"Codemotion\"},\"image\":{\"@id\":\"https:\/\/www.codemotion.com\/magazine\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/Codemotion.Italy\/\",\"https:\/\/x.com\/CodemotionIT\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.codemotion.com\/magazine\/#\/schema\/person\/00344cc4e23bb0758378ab701b57f1a1\",\"name\":\"Luca Ferretti\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.codemotion.com\/magazine\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a7c16ad1483e63c6ae25d1370bfab6252a285d959ed68a5e385f98e66f0b420a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a7c16ad1483e63c6ae25d1370bfab6252a285d959ed68a5e385f98e66f0b420a?s=96&d=mm&r=g\",\"caption\":\"Luca Ferretti\"},\"description\":\"Affezionato al caro vecchio C, passato non troppo recentemente alle pi\u00c3\u00b9 arzigogolate frontiere del Web, Luca Ferretti ha da poco scelto il suo motto su Twitter: I break stuff, I build relationships. \u00c3\u02c6 cos\u00c3\u00ac, tra una ispezione del DOM e una apparizione nella stanza accanto per discutere con il team del frontend di un pixel messo storto, tra una traduzione di Ubuntu e un rebuild dei sorgenti di GNOME (rigorosamente di notte), che trascorre le sue giornate nell'incessante ricerca della perfezione ;-)\",\"url\":\"https:\/\/www.codemotion.com\/magazine\/author\/luca-ferretti\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Property-Based Testing: How to Challenge Your Code (Part 1) - Codemotion","description":"Part 1 on how devs can utilize property based testing to challenge the code they write for better outcomes.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/","og_locale":"en_US","og_type":"article","og_title":"How to Challenge Your Code with Property-Based Testing - Part 1","og_description":"Part 1 on how devs can utilize property based testing to challenge the code they write for better outcomes.","og_url":"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/","og_site_name":"Codemotion Magazine","article_publisher":"https:\/\/www.facebook.com\/Codemotion.Italy\/","article_published_time":"2019-12-11T16:05:35+00:00","article_modified_time":"2021-12-23T13:12:19+00:00","og_image":[{"width":1013,"height":675,"url":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg","type":"image\/jpeg"}],"author":"Luca Ferretti","twitter_card":"summary_large_image","twitter_creator":"@CodemotionIT","twitter_site":"@CodemotionIT","twitter_misc":{"Written by":"Luca Ferretti","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#article","isPartOf":{"@id":"https:\/\/www.codemotion.com\/magazine\/devops\/qa-testing\/how-to-challenge-your-code-with-property-based-testing-part-1\/"},"author":{"name":"Luca Ferretti","@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/person\/00344cc4e23bb0758378ab701b57f1a1"},"headline":"How to Challenge Your Code with Property-Based Testing &#8211; Part 1","datePublished":"2019-12-11T16:05:35+00:00","dateModified":"2021-12-23T13:12:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codemotion.com\/magazine\/devops\/qa-testing\/how-to-challenge-your-code-with-property-based-testing-part-1\/"},"wordCount":677,"publisher":{"@id":"https:\/\/www.codemotion.com\/magazine\/#organization"},"image":{"@id":"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg","keywords":["Codemotion Rome","Testing"],"articleSection":["QA\/Testing"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.codemotion.com\/magazine\/devops\/qa-testing\/how-to-challenge-your-code-with-property-based-testing-part-1\/","url":"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/","name":"Property-Based Testing: How to Challenge Your Code (Part 1) - Codemotion","isPartOf":{"@id":"https:\/\/www.codemotion.com\/magazine\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#primaryimage"},"image":{"@id":"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg","datePublished":"2019-12-11T16:05:35+00:00","dateModified":"2021-12-23T13:12:19+00:00","description":"Part 1 on how devs can utilize property based testing to challenge the code they write for better outcomes.","breadcrumb":{"@id":"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#primaryimage","url":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg","contentUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg","width":1013,"height":675,"caption":"How to Challenge Your Code with Property-Based Testing - Part 1"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codemotion.com\/magazine\/uncategorized\/how-to-challenge-your-code-with-property-based-testing-part-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codemotion.com\/magazine\/"},{"@type":"ListItem","position":2,"name":"DevOps","item":"https:\/\/www.codemotion.com\/magazine\/devops\/"},{"@type":"ListItem","position":3,"name":"QA\/Testing","item":"https:\/\/www.codemotion.com\/magazine\/devops\/qa-testing\/"},{"@type":"ListItem","position":4,"name":"How to Challenge Your Code with Property-Based Testing &#8211; Part 1"}]},{"@type":"WebSite","@id":"https:\/\/www.codemotion.com\/magazine\/#website","url":"https:\/\/www.codemotion.com\/magazine\/","name":"Codemotion Magazine","description":"We code the future. Together","publisher":{"@id":"https:\/\/www.codemotion.com\/magazine\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codemotion.com\/magazine\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codemotion.com\/magazine\/#organization","name":"Codemotion","url":"https:\/\/www.codemotion.com\/magazine\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/logo\/image\/","url":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/11\/codemotionlogo.png","contentUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/11\/codemotionlogo.png","width":225,"height":225,"caption":"Codemotion"},"image":{"@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Codemotion.Italy\/","https:\/\/x.com\/CodemotionIT"]},{"@type":"Person","@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/person\/00344cc4e23bb0758378ab701b57f1a1","name":"Luca Ferretti","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a7c16ad1483e63c6ae25d1370bfab6252a285d959ed68a5e385f98e66f0b420a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a7c16ad1483e63c6ae25d1370bfab6252a285d959ed68a5e385f98e66f0b420a?s=96&d=mm&r=g","caption":"Luca Ferretti"},"description":"Affezionato al caro vecchio C, passato non troppo recentemente alle pi\u00c3\u00b9 arzigogolate frontiere del Web, Luca Ferretti ha da poco scelto il suo motto su Twitter: I break stuff, I build relationships. \u00c3\u02c6 cos\u00c3\u00ac, tra una ispezione del DOM e una apparizione nella stanza accanto per discutere con il team del frontend di un pixel messo storto, tra una traduzione di Ubuntu e un rebuild dei sorgenti di GNOME (rigorosamente di notte), che trascorre le sue giornate nell'incessante ricerca della perfezione ;-)","url":"https:\/\/www.codemotion.com\/magazine\/author\/luca-ferretti\/"}]}},"featured_image_src":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000-600x400.jpg","featured_image_src_square":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000-600x600.jpg","author_info":{"display_name":"Luca Ferretti","author_link":"https:\/\/www.codemotion.com\/magazine\/author\/luca-ferretti\/"},"uagb_featured_image_src":{"full":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg",1013,675,false],"thumbnail":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000-150x150.jpg",150,150,true],"medium":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000-300x200.jpg",300,200,true],"medium_large":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000-768x512.jpg",768,512,true],"large":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg",1013,675,false],"1536x1536":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg",1013,675,false],"2048x2048":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg",1013,675,false],"small-home-featured":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000.jpg",100,67,false],"sidebar-featured":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000-180x128.jpg",180,128,true],"genesis-singular-images":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000-896x504.jpg",896,504,true],"archive-featured":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000-400x225.jpg",400,225,true],"gb-block-post-grid-landscape":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000-600x400.jpg",600,400,true],"gb-block-post-grid-square":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/12\/solar-panels-2019323_1280_347fe9e015f88aac0dac9deb012fca37_2000-600x600.jpg",600,600,true]},"uagb_author_info":{"display_name":"Luca Ferretti","author_link":"https:\/\/www.codemotion.com\/magazine\/author\/luca-ferretti\/"},"uagb_comment_info":0,"uagb_excerpt":"You need to challenge the code you write by moving away from the comfort zone of known valid inputs by feeding with unforeseen data that can disprove your safety illusions.","lang":"en","_links":{"self":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts\/2076","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/comments?post=2076"}],"version-history":[{"count":4,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts\/2076\/revisions"}],"predecessor-version":[{"id":3380,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts\/2076\/revisions\/3380"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/media\/2077"}],"wp:attachment":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/media?parent=2076"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/categories?post=2076"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/tags?post=2076"},{"taxonomy":"collections","embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/collections?post=2076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}