{"id":1034,"date":"2014-01-05T15:20:22","date_gmt":"2014-01-05T15:20:22","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=1034"},"modified":"2014-01-17T15:45:10","modified_gmt":"2014-01-17T15:45:10","slug":"unit-testing-in-f","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/unit-testing-in-f\/","title":{"rendered":"Unit testing in F#"},"content":{"rendered":"<p>There are several libraries for writing unit tests in F#. <a href=\"https:\/\/github.com\/fsharp\/FsUnit\" title=\"FsUnit\" target=\"_blank\">FsUnit<\/a> allows us to reuse xUnit, NUnit or MbUnit.<\/p>\n<p>So using FsUnit with xUnit do the following<\/p>\n<ol>\n<li>Add a new Library project<\/li>\n<li>Using NuGet, add a reference to FsUnit.Xunit<\/li>\n<\/ol>\n<p>Now we can write our tests using the following <\/p>\n<pre class=\"brush: fsharp; title: ; notranslate\" title=\"\">\r\nopen FsUnit.Xunit\r\nopen Xunit\r\n\r\nmodule Tests =\r\n\r\n   &#x5B;&lt;Fact&gt;]\r\n   let ``add two numbers`` () =\r\n      let m = new Mathematics()\r\n      m.add 1 3 |&gt; should equal 4\r\n<\/pre>\n<p>using backtick notation for identifers is useful for helping us write human readable test names.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are several libraries for writing unit tests in F#. FsUnit allows us to reuse xUnit, NUnit or MbUnit. So using FsUnit with xUnit do the following Add a new Library project Using NuGet, add a reference to FsUnit.Xunit Now we can write our tests using the following open FsUnit.Xunit open Xunit module Tests = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1034","post","type-post","status-publish","format-standard","hentry","category-f"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/1034","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=1034"}],"version-history":[{"count":8,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/1034\/revisions"}],"predecessor-version":[{"id":1103,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/1034\/revisions\/1103"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=1034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=1034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=1034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}