Fitnesse

Ever since reading about Fit – the integrated test framework by Ward Cunningham – I wanted to try it out but I never gave myself a chance until tonight. Apparently there are some different incarnations of Fit but because there might be some potential for implementing Fit at our shop I think Fitnesse – a wiki web server built on top of the fit framework – might be a good choice.

It took me some fiddling to get it running so I’m posting a recap of my trials below.

The first thing I did was download the “official release” and give it a go. Booting up the server was no problem and I had quickly created the infamous Division class with Visual Studio 2005. Fitnesse refused to load my .NET 2.0 assemblies though. Every time it complained that it could not find the type Division and the “assemblies searched” list would be empty. Even though my dll was clearly there.

Thinking this might be a .NET versioning problem I set out to search and found a few useful references. First one is Cory Foy’s basic tutorial . A must-read for anyone who want’s to run Fitnesse in a .NET environment. The post itself is great but the follow-up in the comments was particulary useful for me.

One of the final comments had a link to a post on Jeff’s Bits which provides an excellent guide to porting the Fitnesse.NET source to version 2.0 with Visual Studio 2005 and also the next pieces of information in my quest to get it all running. I started out following the guide and intended to compile the source myself but ran into a huge number of conversion errors so ended up using Jeff’s handy conversion pack instead.

Still no luck in Fitnesse though but at least it actually looked in my .NET 2.0 assemblies. It now complained that it could not cast my Division class to fit.Fixture even though I could clearly follow it’s line in the Visual Studio 2005 object browser. After some cursing and a little bit of luck I found this message in the yahoo “agile testing” group. It didn’t provide an immediate solution to my problem but the comments in that thread inspired me to go to the Fitnesse group and look further. After actually using the search function of that group I finally found the final piece of information in this message.

As it turned out I had fit.dll loaded multiple times and as Micah Martin of Object Mentor has eloquently put it: “.NET chokes with this”. Continue reading “Fitnesse”

Castle

After a few weeks of wondering why the Cassini web server distributed with Castle refused to run with the 2.0 framework but today with great luck I stumbled upon the missing piece of information in Google’s cache of Castle’s FishEye data here. I just copied the contents of that config into a new config file in Cassini’s directory and now everything works beautifully.

[code]< ?xml version="1.0"?>









[/code]

I tried repeating this trick on my laptop with the config you see above but strangely enough this failed… It was only after I went back to google for the original config and placed that in Cassini’s directory that things started working on my laptop too… Maybe a slight error on my part in copying that config file yesterday or maybe it was just a gremlin…
Continue reading “Castle”

Monad,

Last few weeks I’ve been toying with Msh a.k.a. Monad, the new Microsoft Command Shell. I remember reading somewhere that you could use Windows Forms but that it was impossible to bind handlers to events. Luckely, this is not true. It does require calling an exotic method (for a C# programmer at least) with an ugly name but once you get over this it’s not hard at all.

A Button instance has a Click event. In C# one could bind a handler to this event by doing something like:

[code]button.Click += delegate(object sender, EventArgs e)
{
MessageBox.Show(“Clicked”);
}[/code]

In Monad we cannot use the familiar += syntax but this does not mean that we cannot bind event handlers. But how then can we accomplish something similar? Let’s inspect a Button instance using the get-member cmdlet:

[code]$button = new-object System.Windows.Forms.Button
$button | get-member | more[/code]

If you execute the above script you can see the strangely named add_Click and remove_Click methods scroll by. These methods are equivalent to += and -= operators as used for events in C#. Binding an event handler to a Button instance in Monad can thus be easily accomplished by doing something like this:

[code]$button.add_Click({ write-host ‘OnClick’ })[/code]

As you’ve probably guessed, the get_ and set_ methods are the properties getters and setters but in Monad we can use the actual property itself:

[code]$button.Text = ‘I am a button me'[/code] Continue reading “Monad,”

PHP5

Just a quick note on getting PHP5 to work with Apache 2.2: make sure the LoadModule and <IfModule> sections are in place. The LoadModule line should be added when you install using the ports collection but I was missing the <IfModule> section but after manually adding this I was fine:

[code]
DirectoryIndex index.php index.html


Addtype application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
[/code]

It’s sort of described here
but it’s a little bit out of date it seems. You don’t need the AddModule line anymore and can just reference php5_module directly. Continue reading “PHP5”

MySQL

It always takes a good night of sleep for me to get things working in FreeBSD. I usually tend to start these tasks too late when I’m not completely with it anymore and things go wrong often right from the start.

The day after I’m usually able to complete what I set out to do and this time, installing MySQL on FreeBSD, it was no different. I kept getting “Couldn’t not connect to bla bla socket bla localhost etc.” errors and mysqld would not run no matter how bad I wanted it to.

Tonight, I read the manual a little more carefully and tried changing the owner of the mysql data directories (/var/db/mysql) to my own username before running mysqld manually and the thing finally started. Then I looked a little better at the mysql-server.sh script in /usr/local/etc/rc.d and there it was:

To enable mysql you need to add mysql_enable=”YES” to your rc.conf. Well, I changed owner of the /var/db/mysql directory back to mysql, added mysql_enable=”YES” to rc.conf, rebooted and voila. It was working perfectly after all… The only thing missing was that line in rc.conf.

Ah well, maybe I can run mysql 5.0 after all. I started with this version but after it seemed to fail I tried 4.1. Now I deinstalled 4.1 (again) and as I’m typing this 5.0 is compiling. I’m hoping things will work right after the reboot because that line is still there. Continue reading “MySQL”

JavaScript

When I got really serious with my JavaScript and understood it well enough I always wanted to have some kind of unit testing framework. Unfortunately though there really does not seem to be anything available that really works and also has some kind of documentation on how to use it. I’ve been following JsUnit for a few year now but nobody seems to be using it. I tried using it myself over the years for mulitple times but like everyone else, I too seem to be lacking the necessary brain capacity to figure it out. So this weekend I incubated one myself and you know what? It’s not even that hard at all…

For my immediate testing needs it turned out I only needed two methods: areEqual and areEqualArrays. So I wrapped these into a Assert object:

[JavaScript]var Assert = {
areEqual: function(expected, actual, msg) {
if(expected != actual)
Kinky.fail(expected, actual, msg);
},
areEqualArrays: function(expected, actual, msg) {
if(expected.length != actual.length) {
Kinky.fail(expected, actual, msg);
return;
}
expected.each(function(item, index) {
Assert.areEqual(item, actual[index]);
});
}
}[/JavaScript]

As you can see the Assert object depends on the Kinky object so
let’s have that as well:

[JavaScript]var Kinky = {
failed: false,
output: new Alerter(),
fail: function(expected, actual, msg) {
if(this.failed) return;
this.failed = true;
this.output.writeLine(“Expected: ” + expected + “, was: ” + actual + “: ” + msg);
},
run: function(testFixture, output) {
if(output)
this.output = new Writer($(output));;

for(test in testFixture) {
testFixture[test]();
if(this.failed) return;
this.output.writeLine(test + ” done.”);
}
}
}[/JavaScript]

The last thing we need is the Alerter that’s referenced by the Kinky class:
[JavaScript]var Alerter = Class.create();
Alerter.prototype = {
initialize: function(beSilent) { this.beSilent = beSilent; },
writeLine: function(str) { if((!this.beSilent) || Kinky.failed) alert(str); }
}[/JavaScript]

The Alerter is somewhat a last-ditch effort to raise test messages. We usually want to have some more friendly output so we have this Writer class that’s able to redirect messages to document elements:

[JavaScript]var Writer = Class.create();
Writer.prototype = {
initialize: function(elm) { this.elm = elm; },
writeLine: function(str) { new Insertion.Bottom(this.elm, str + “
“); }
}[/JavaScript]

To have Kinky use it we need to assign it to Kinky.output like so:
[JavaScript]Kinky.output = new Writer($(‘theOutputElement’));[/JavaScript]

Or use the extended run function:
[JavaScript]Kinky.run(someTestFixture, ‘theOutputElement’);[/JavaScript]

The $ function is a Prototype function that returns the DOM node confirming to the id supplied. Continue reading “JavaScript”

"JavaScript,

A few year’s ago I was doing a graduation project at Philips Medical Systems together with a fellow student. Our task was to implement a browser interface to design flowcharts for work instructions. The content would be stored using their custom CMS. Eventually, our solution was based around a grid where each cell would define it’s own layout and could validate itself according to it’s neighbours in the grid. The whole thing was JavaScript based and persistence was handled by posting a dynamically created form to a PHP script.

Although we never got to fully clean up the implementation, the thing did work pretty well and was (and still is) pretty advanced JavaScript technology. It had to run in some kind of weird “template” system designed by the “guys that came before me” and that was pretty nasty but eventually we got stuff to work around and with that too.

Now, a few years later I had almost completely lost my touch with JavaScript if it wasn’t for a particular web-based problem we couldn’t “ViewState” our way out of. The client wanted drill down lookups and my boss wanted a generic solution. Our current solution is very generic but requires the users to postback at least a dozen times to get to the required lookup result. Although it works it rates pretty bad on the usability scales so now I’ve re-implemented the whole thing using JavaScript instead of relying on post-backs and .NET controls do to their job…

And mama, mia! What the #$ck have I been doing lately? Sleeping? Why don’t I use JavaScript in my projects anymore like I used to do… JavaScript kicks ass! Now that I’ve been from QBasic to Pascal to Assembler, Visual Basic, Delphi, Java, VBScript (ASP), C, C++, PHP, Python, Visual Basic.NET, C#, Smalltalk, Ruby and Lisp I can say that there are quite a few languages I would like to work with at the end of that list but that’s not an option right now unfortunately. Luckely though there’s JavaScript which allows me to do some amazing things… Even if it has to be in a browser. Continue reading “"JavaScript,”

ASP.NET

Today I ran into a “server application unavailable” error and sure enough, upon checking the logs I found something like this:

Failed to execute the request because the ASP.NET process
identity does not have read permissions to the global assembly cache. 
Error: 0x80070005 Access is denied.

At first I could not find a solution but a second search turned out a link to Zupancic Perspective. The post itself is nice but what really did it for me was the comment by Robert Burkhall:

The simplest way to handle this error is to do the following;

1) Open IIS
2) Select the Folder
3) Right Button Click on the Folder
4) Click Permission Wizard
5) All should be ok

Which I did, just started up the Permission Wizard and went through it blindly by clicking on “Next” repeatedly. After that I tried again and the ASP.NET 2.0 web app is finally running.
Continue reading “ASP.NET”

Visual

Much (too much maybe) has been said about Visual Studio 2005 already but if you’re working with Visual Studio 2003 for your daily living (like I am) you want 2005. For me, there’s one new addition that absolutely does it no matter what can be said about 2003: automatic renaming.

I tend to mess around with my class names renaming them from this to that to see whatever looks and feels best. With 2003 and editors you soon resort to some kind of Find/Replace command which tends to be somewhat error prone (for me at least). Visual Studio 2005 replaces your typenames automagically when you rename your class files. No more error prone search actions for me: I’ll just blame the IDE from now on.

Oh and Smalltalkers and Lispers: please realize I already know and love the languages you also love so much. I’ve witnessed their awesome powers and can get a little frustrated sometimes because I cannot make make my living using them (yet). The .NET framework is the best I can get at this shop for now… Continue reading “Visual”

God

Last week I found this link where you can download Scott Adams’ “God’s Debris” for free. Because I like Scott Adams, books in general and free books even more so I immediately downloaded it. A few days ago I started reading it and it must be one of the best books I have ever read. It reminded me of the dialogues of Aristotle and Plato although it’s a lot easier to read. Although his philosophical insights may not always be as accurate as those of the masters of old, Scott sure makes you think.

Be warned though – this book may change your whole perspective on reality. Continue reading “God”