Translate

Tuesday, 11 June 2013

Slim help (no pun intended!) !

Before I begin this post, let me say this -

Do not forget to leave a "Thank you" comment if this helped you in using Slim. I know the worth of this post as there is hardly any online help (simple ones that is) on Slim!

Even though I started using Slim 3-4 years back, I still find it can behave unpredictably, unlike other tools so I am posting some tips here. :P

Tip #1 - Use the Format button on the Wiki but wait! It may format your wiki code but it is not a magic wand and you must use it as an informed user. For instance, if you write a wiki line of code like "'{some line here |' the "{" will not be declared as an error!! So, the Format button only helps experienced Slim/FitNesse coders.

Tip #2 - There is no logic to this tool. It is as open for "trial and error" as you could imagine, so go ahead and try all the syntax that you know!

Well, okay, jokes apart, here is the real one!

To start using Slim, you will need the Fitnesse.jar file and Slim Download Fitnesse and Slim. Extract it after downloading and navigate to your Fitnesse folder (through command prompt) and type
"java - jar fitnesse.jar " (or the name of the .jar file as may be). This will launch your fit server on port "80". If  the port is not available, type "java -jar fitnesse.jar -p 9888 (or any other number)".

In your favorite browser, type localhost (this example is based on Windows 7 Home Basic (no IIS default)): and you will be at home with Fitnesse ! :)

Create a new page "HelloWorld" by typing it in the address bar of the browser and an editable text box will open.

Delete the !contents line. In the empty text box, enter the following lines -

!define TEST_SYSTEM {slim}
!define TEST_RUNNER {e:\fitSharp\Runner.exe}

!define COMMAND_PATTERN {%m -r fitSharp.Slim.Service.Runner,e:\fitSharp\fitSharp.dll %p}

!path DllDrive:\yourDLLpath\YourDllLibrary.dll

Explanation
The first line indicates that you want to use Slim - default is "fit". The second line says use Slim Runner to execute the tests in your page. The third line is the service that is to be used by Slim and the location of the Slim library. The 4th line is the path where your C# domain library resides! That is it! 

The "!" mark is used wherever you want to let Fitnesse know that the following lines should not be used as a wiki code and formatted!

There are various techniques for writing Acceptance tests and it is beyond the scope of this post so I will introduce the tools used in Slim - tables.

There are Decision, Scenario, Table, Script, query, import....tables. Each has its own applicability and to learn about them you can take a look here.

Scenario table

Scenario tables are my favorite in Slim because of my inclination towards BDD (Behavior Driven Development). 

A scenario table, as the name indicates, describes scenarios (use cases/user stories) and by itself does not do anything so if you wish to impress somebody in your team/management, you can simply declare a scenario like this and it will show "Green"!

|Scenario||myScenario|

|myScenario|

Below is an example screen(s) of a scenario table with the Slim script following it and the C# code after it.

The script of the last scenario in the script has not been included and you can use that as an exercise !

Similarly, the class name and the namespace names have been left out in the C# screenshot that you can use as an exercise!











No comments: