<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>vi-kan.net &#187; Fit4Delphi</title>
	<atom:link href="http://blog.vi-kan.net/tag/fit4delphi/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.vi-kan.net</link>
	<description>{ TODO -oVegar : insert clever text here}</description>
	<lastBuildDate>Mon, 28 Nov 2011 17:05:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Running FitNesse tests from the command line</title>
		<link>http://blog.vi-kan.net/2009/running-fitnesse-tests-from-the-command-line/</link>
		<comments>http://blog.vi-kan.net/2009/running-fitnesse-tests-from-the-command-line/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 22:52:00 +0000</pubDate>
		<dc:creator>Vegar</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Fit4Delphi]]></category>
		<category><![CDATA[FitNesse]]></category>

		<guid isPermaLink="false">http://blog.vi-kan.net/2009/running-fitnesse-tests-from-the-command-line/</guid>
		<description><![CDATA[Using FitNesse to write and run test is nice, but sometimes you want to run the tests as part of an automatic build cycle. FitNesse has this possibility, and fit4delphi comes with a testrunner that makes it possible with delphi code as well. In the fit4delphi package, inside the testrunner folder, you will find a [...]]]></description>
			<content:encoded><![CDATA[<p><img style="border-right-width: 0px; margin: 0px 0px 0px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://blog.vi-kan.net/wp-content/uploads/2009/09/image.png" border="0" alt="image" width="240" height="136" align="right" /> Using FitNesse to write and run test is nice, but sometimes you want to run the tests as part of an automatic build cycle. FitNesse has this possibility, and fit4delphi comes with a testrunner that makes it possible with delphi code as well.</p>
<p><span id="more-96"></span></p>
<p>In the fit4delphi package, inside the testrunner folder, you will find a project named DelphiTestRunner.dproj. You can use this project to automatically run a test, or a suite of tests, and store the result as a file. To do his, you have to tell the testrunner where the FitNesse server is running, and which file and in what format the result should be store in. This is done with command line parameters in the given form:</p>
<blockquote><p>DelphiTestRunner.exe [options] host port page</p></blockquote>
<p>Host and port must be the same as specified when starting FitNesse. The page parameter is the url for the wiki page you want to test. All subpages of this page will also be tested.</p>
<p>There are multiple options you can specify.</p>
<ul>
<li>-debug<br />
This option will print FitNesse protocol actions to the console.</li>
<li>-v<br />
This option should give a verbose output about test progress to the console, but personally, I can’t make it work…</li>
<li>-results file<br />
The result of the testrun is saved to a textfile with the given name.</li>
<li>-html file<br />
The result of the testrun is saved to a html file with the given name.</li>
<li>-xml file<br />
The result of the testrun is saved to a xml file with the given name. The xml format is given <a title="FitNesse.UserGuide.RestfulTests" href="http://fitnesse.org/FitNesse.UserGuide.RestfulTests" target="_blank">in the userguide</a>.</li>
<li>-nopath<br />
This option will make FitNesse ignore !path options specified in the wiki pages.</li>
<li>-suiteFilter filter<br />
Specifying a filter will only run pages with tags matching the filter. You can read more about this <a title="FitNesse.UserGuide.TestSuites.TagsAndFilters" href="http://fitnesse.org/FitNesse.UserGuide.TestSuites.TagsAndFilters" target="_blank">in the userguide</a>.</li>
</ul>
<p>An example of a command line could be some thing like this:</p>
<blockquote><p>DelphiTestRunner.exe –html results.html localhost 80 MyTestSuite</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.vi-kan.net/2009/running-fitnesse-tests-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FitNesse + Delphi –&gt; Fit4Delphi</title>
		<link>http://blog.vi-kan.net/2009/fitnesse-delphi-fit4delphi/</link>
		<comments>http://blog.vi-kan.net/2009/fitnesse-delphi-fit4delphi/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 13:59:28 +0000</pubDate>
		<dc:creator>Vegar</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Fit4Delphi]]></category>
		<category><![CDATA[FitNesse]]></category>

		<guid isPermaLink="false">http://blog.vi-kan.net/?p=76</guid>
		<description><![CDATA[I have been thinking about FitNesse for a couple of weeks now. It seems to be near to perfect for testing the type of code that I&#8217;m currently writing. A lot of calculations with a lot of rules, odd cases and exceptions. So I finally started to check it out, to see if it is [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-85" style="margin: 0px 0px 0px 10px; display: inline; border-width: 0px;" title="FitNesseLogo" src="http://blog.vi-kan.net/wp-content/uploads/2009/08/FitNesseLogo.gif" alt="FitNesseLogo" width="90" height="90" />I have been thinking about <a href="http://fitnesse.org/">FitNesse</a> for a couple of weeks now. It seems to be near to perfect for testing the type of code that I&#8217;m currently writing. A lot of calculations with a lot of rules, odd cases and exceptions. So I finally started to check it out, to see if it is possible to use FitNesse to test code written in delphi.<span id="more-76"></span> After some googling, I found a lot of references to the fact that it is possible, but not much on how. There ain’t much references to people actually using it either.  I found two projects, though, <a href="http://code.google.com/p/fit4delphi/">Fit4Delphi</a> and <a href="http://fitnesse.org/FrontPage.FitServers.DelphiFit">DelphiFIT</a>. It looks like DelphiFIT has been merged with the Fit4Delphi project, so there is only one solution left for FitNesse with Delphi. If it is any good, one is all you need, though.  At first, it’s a bit unclear what components are playing together in FitNesse. There are two main parts of the system, with two different roles. The first part is the one doing the actual testing bit. The second is a development environment in the form of a wiki, made for writing, invoking and maintaining tests.</p>
<h2>Get it running</h2>
<p>So let see if we can make this work. Fit4Delphi comes with a older version of FitNesse. You can choose to use this version, or you can get a newer version from <a href="http://fitnesse.org">fitnesse.org</a>. I like new shiny things, so I downloaded a brand new fitnesse.jar. Assuming that java already exists on your computer, fitnesse.jar is all you need to get going. Put it in a folder somewhere, e.g. c:\fitnesse\, and run</p>
<pre class="brush: plain; gutter: false; title: ;">c:\fitnesse\java -jar fitnesse.jar</pre>
<p>Fitnesse will now unpack it self before it starts. If you later want to upgrade to a newer version of FitNesse, you can download a new jar-file and new resources will be extracted next time you start FitNesse.  When FitNesse starts, it will tell you what version it is and what port it is running on. It will also tell you a couple of other things, but the port number is what we need right now. The port number defaults to 80, the standard http port. So fire up you webbrowser, and navigate to <a href="http://localhost:80">http://localhost:80</a>, and you will be presented with the default front page for FitNesse.  To the left, you have a tree-structure showing what pages exists in the wiki, and to the right you have the content for the current page. In the FitNesse branch of the tree, you can find the user guide for FitNesse amoung all the acceptance tests for FitNesse itself.  On the FrontPage, click the edit-button to the left. At the bottom of the page, write the name of your new testsuite, ‘DelphiTests’, or what ever. It need to be a <a href="http://fitnesse.org/FitNesse.UserGuide.WikiWord">‘WikiWord’</a>, though. When you save the document, you will see your inserted text together with a ‘[?]’. This means that the wiki sees your wikiword as a title for a page, but can’t find the page itself. When clicking on the questionmark, the wiki will create the page, and let you edit it.  So let’s start with a simple table. Fill out the new page with something like the following:</p>
<pre class="brush: plain; gutter: false; title: ;">|test table|
|in value|out value?|
|1|2|</pre>
<p>After saving, you will see your table nicely formatted. Is there a Test button to the left? If not, click the Properties-button, and choose Test as page type. Now, click the Test-button…  Nothing happends, right?  FitNesse finds the table and want it to be tested, but can’t find anyone willing to work. It needs to know who to call for the job. It is done by defining the <a href="http://fitnesse.org/FitNesse.UserGuide.CustomizingTestExecution">‘COMMAND_PATERN’</a> variable. When testing delphi code, we will need  DelphiFitServer.exe to do the work for us, so we give FitNesse the path to this executable. I have copied both DelphiFitServer.exe and fit.bpl to a ‘bin’-folder in my FitNesse-folder. You will find the source in \fit4delphi\fitserver\ and \fit4delphi\fit\.</p>
<pre class="brush: plain; gutter: false; title: ;">!define COMMAND_PATTERN {bin\DelphiFitServer.exe -v %p}</pre>
<p>The –v parameters tell DelphiFitServer to print out messages, and the %p parameter represents the <a href="http://fitnesse.org/FitNesse.UserGuide.MarkupPath">path</a> where DelphiFitServer should look for fixtures. FitNesse builds this path from classpath-settings in the wiki. Let’s include one in our page:</p>
<pre class="brush: plain; gutter: false; title: ;">!path bin\*.bpl</pre>
<p>Let’s hit that Test button again and see if there is any progress.  This time we get a lot of yellow on our page. While red tells us that a test did not pass, yellow tells us that something went wrong when trying execute the test. As you can see, DelphiFitServer couldn’t find fixture for our table. If you click the ‘Output Captured’ sign in the right corner, you will get some details on the execution. You can see what exe-file was used, and what bpl-files was loaded. We now need to add some testcode on our own.</p>
<h2>Writing our first fixture</h2>
<p>From the yellow text, we found that we need a class named ‘TestTable’. Acctually, FitNesse is quite flexible when it comes to naming. You can read more about it <a title="Graceful Naming" href="http://fitnesse.org/FitNesse.UserGuide.GracefulName">the documentation</a>, but I will disclose that a class named ‘TTestTable’ should be accepted.  So lets create a new delphi package. Add a reference to fit.bpl and the source path for fit4delphi\fit\source, fit4delphi\fit\source\exception and fit4delphi\RegExpr. Create a new unit, and define a new class deriving from TColumnFixture. You will need the file ColumnFixture in your uses section for this to compile. You will also need to enable detailed rtti for your class, and register it with a call to RegisterClass:</p>
<pre class="brush: delphi; title: ;">unit fitTestTable;

interface

uses
  ColumnFixture;

type
  {$M+}
  {$METHODINFO ON}
  TTestTable = class(TColumnFixture)
  published
  end;

implementation

uses
  Classes;

{ TTestTable }

initialization
  RegisterClass(TTestTable)

end.</pre>
<p>Build the new package, and move it to the bin folder of your FitNesse installation. Run the test again, and you will find that there is now three exceptions instead of one. Progress!  This time, it chokes on the column titles. Could not find field: in value. Well, lets add it, then. A published property named InValue of type double should do.  Compile… Copy… Test…  One down, two to go.  Of course it choked on the next column also. This time we need to add a function named OutValue returning a double.  Let’s fake the implementation for now, and just return 0.</p>
<pre class="brush: delphi; title: ;">   TTestTable = class(TColumnFixture)
  private
    FInnValue: double;
  published
    property InnValue: double read FInnValue write FInnValue;
    function OutValue: double;
  end;</pre>
<p>Now, that got rid of both the remaining exceptions, but leaves us with some ugly red spots. This is actually good though: Our test runs with out problems, but fails. I will leave it up to you to make the test pass. It shouldn’t be to hard, and the reward of green colour should be enough to make you wanna write some real tests.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vi-kan.net/2009/fitnesse-delphi-fit4delphi/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
