{"id":705,"date":"2009-11-08T10:48:00","date_gmt":"2009-11-08T09:48:00","guid":{"rendered":"http:\/\/www.navision-blog.de\/2009\/02\/23\/getting-started-with-naturalspec\/"},"modified":"2009-11-08T10:53:06","modified_gmt":"2009-11-08T09:53:06","slug":"getting-started-with-naturalspec","status":"publish","type":"post","link":"http:\/\/www.navision-blog.de\/blog\/2009\/11\/08\/getting-started-with-naturalspec\/","title":{"rendered":"&quot;Getting started&quot; with NaturalSpec &ndash; (Updated 08.11.2009)"},"content":{"rendered":"<p>In my last article (<a href=\"http:\/\/www.navision-blog.de\/2009\/02\/23\/introducing-naturalspec-a-dsl-for-testing-part-i\/\">Introducing NaturalSpec \u2013 A Domain-specific language (DSL) for testing<\/a>) I used NaturalSpec in two small samples. This time I will show how we can set up a <a href=\"http:\/\/code.google.com\/p\/natural\/\">NaturalSpec<\/a> environment to write our first automatically testable scenarios.<\/p>\n<h5>1. Choosing an IDE<\/h5>\n<p>The first step is to choose an integrated development environment for NaturalSpec. At the current project status you should be able to use NaturalSpec with Visual Studio 2008, Visual Studio 2010 beta 2, the freely available <a href=\"http:\/\/msdn.microsoft.com\/en-us\/vsx2008\/products\/bb933751.aspx\">Visual Studio 2008 Shell<\/a> or the free IDE <a href=\"http:\/\/www.icsharpcode.net\/OpenSource\/SD\/\">SharpDevelop 3.0<\/a>.<\/p>\n<h5>2. Installing the testing framework<\/h5>\n<p>As NaturalSpec uses <a href=\"http:\/\/www.nunit.org\/index.php\">NUnit<\/a> as the underlying testing framework we have to install NUnit 2.5. I also recommend installing <a href=\"http:\/\/testdriven.net\/default.aspx\">TestDriven.Net<\/a> in order to get a Unit Test runner within Visual Studio.<\/p>\n<h5>3. Installing F#<\/h5>\n<p>NaturalSpec is completely written in <a href=\"http:\/\/en.wikipedia.org\/wiki\/F_Sharp_programming_language\">F#<\/a> and all specs will also be written in F#. This doesn\u2019t imply you have to learn programming in F# but we need the F# compiler to get things working. You can download the <a href=\"http:\/\/www.microsoft.com\/downloads\/details.aspx?FamilyID=b55f0532-ac3c-4106-918c-5586a953a7da&amp;displaylang=en\">F# October 2009 CTP<\/a> from the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/fsharp\/default.aspx\">Microsoft F# Developer Center<\/a>.<\/p>\n<h5>4. Downloading the latest version of NaturalSpec<\/h5>\n<p>You can download a .zip with the <a href=\"http:\/\/code.google.com\/p\/natural\/\">latest NaturalSpec libraries from GoogleCode<\/a>.<\/p>\n<h5>5. Creating a spec<\/h5>\n<p>This part is written for using Visual Studio 2008. If you use SharpDevelop or Visual Studio 2008 Shell this might differ in some detail.<\/p>\n<p>Start Visual Studio 2008 and create a new F# class library.<\/p>\n<p><img loading=\"lazy\" class=\"bordered\" title=\"Creating a spec project\" border=\"0\" alt=\"Creating a spec project\" src=\"http:\/\/www.navision-blog.de\/images\/GettingstartedwithNaturalSpec_A7B1\/image.png\" width=\"500\" height=\"354\" \/><\/p>\n<p>Rename <em>Module1.fs<\/em> in <em>ListSpec.fs<\/em> and delete <em>script.fsx<\/em> from the project:<\/p>\n<p><img loading=\"lazy\" class=\"bordered\" title=\"Solution explorer\" border=\"0\" alt=\"Solution explorer\" src=\"http:\/\/www.navision-blog.de\/images\/GettingstartedwithNaturalSpec_A7B1\/image_3.png\" width=\"248\" height=\"146\" \/><\/p>\n<p>Create a folder \u201cLib\u201d and unzip the NaturalSpec libraries into it.<\/p>\n<p>Add <em>NaturalSpec.dll<\/em> and <em>nunit.framework.dll<\/em> as references to your project:<\/p>\n<p><img loading=\"lazy\" class=\"bordered\" title=\"Adding project references\" alt=\"Adding project references\" src=\"http:\/\/www.navision-blog.de\/images\/GettingstartedwithNaturalSpec_A7B1\/image_4.png\" width=\"482\" height=\"406\" \/><\/p>\n<p>Copy the following code into ListSpec.fs:<\/p>\n<pre class=\"code\"><span style=\"color: blue\">module <\/span>ListSpec<\/pre>\n<pre class=\"code\"><span style=\"color: blue\">open <\/span>NaturalSpec\n\n[&lt;Scenario&gt;]\n<span style=\"color: blue\">let <\/span>When_removing_an_3_from_a_small_list_it_should_not_contain_3() =\n  Given [1;2;3;4;5]\n    |&gt; When removing 3\n    |&gt; It shouldn't contain 3\n    |&gt; Verify<\/pre>\n<p>If you have TestDriven.Net installed you can run your spec via right click in the solution explorer:<\/p>\n<p><img class=\"bordered\" title=\"Run spec with TestDriven.net\" alt=\"Run spec with TestDriven.net\" src=\"http:\/\/www.navision-blog.de\/images\/GettingstartedwithNaturalSpec_A7B1\/image_5.png\" width=\"295\" \/><\/p>\n<p>If you don\u2019t like the TestDriven.Net test runner you might want to use the NUnit GUI runner. The output should look like:<\/p>\n<p><a href=\"http:\/\/www.navision-blog.de\/images\/GettingstartedwithNaturalSpec_A7B1\/image_6.png\"><img loading=\"lazy\" class=\"bordered\" title=\"NUnit Gui runner\" border=\"0\" alt=\"NUnit Gui runner\" src=\"http:\/\/www.navision-blog.de\/images\/GettingstartedwithNaturalSpec_A7B1\/image_thumb.png\" width=\"500\" height=\"264\" \/><\/a><\/p>\n<p>In addition the test runner should produce a Spec output file with the name \u201cSpec.txt\u201d within the same folder.<\/p>\n<h5>Summary<\/h5>\n<p>In a minimal environment you need <a href=\"http:\/\/www.icsharpcode.net\/OpenSource\/SD\/\">SharpDevelop<\/a>, the <a href=\"http:\/\/www.microsoft.com\/downloads\/details.aspx?FamilyID=b55f0532-ac3c-4106-918c-5586a953a7da&amp;displaylang=en\">F# compiler<\/a>, <a href=\"http:\/\/www.nunit.org\/index.php\">NUnit<\/a> and the <a href=\"http:\/\/code.google.com\/p\/natural\/\">NaturalSpec libraries<\/a> for using NaturalSpec. <\/p>\n<p>In the next post I will show how you can <a href=\"http:\/\/www.navision-blog.de\/2009\/02\/23\/using-naturalspec-to-create-spec-for-c-projects\/\">use NaturalSpec to create a spec for C# projects<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my last article (Introducing NaturalSpec \u2013 A Domain-specific language (DSL) for testing) I used NaturalSpec in two small samples. This time I will show how we can set up a NaturalSpec environment to write our first automatically testable scenarios. 1. Choosing an IDE The first step is to choose an integrated development environment for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,448,524],"tags":[533,664,666,219,531,633],"_links":{"self":[{"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/posts\/705"}],"collection":[{"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/comments?post=705"}],"version-history":[{"count":13,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/posts\/705\/revisions"}],"predecessor-version":[{"id":906,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/posts\/705\/revisions\/906"}],"wp:attachment":[{"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/media?parent=705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/categories?post=705"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.navision-blog.de\/blog\/wp-json\/wp\/v2\/tags?post=705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}