Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fitnesse test against empty string result

Tags:

fitnesse

I'm using Fitnesse SliM and I want to check if the result of a fixture is the empty string. Leaving the result field in Fitnesse empty just results in an ignored test which is obviously not what I want. I could solve this by extending the fixture code, but I wonder if this can be handled within Fitnesse itself.

like image 467
Maurits Rijk Avatar asked Jul 05 '10 09:07

Maurits Rijk


People also ask

How do I run a FitNesse test?

To open FitNesse, open your browser and type: http://localhost:<portnumber>. In this case, the port number is 2222. So here, if you can see the Tests dropdown, we can create a “Suite page” as well as a “Test Page”. When you create a suite, all the test scripts within that suite will be executed.

What is fixture in FitNesse?

A fixture is the class that FitNesse and Slim use to process a particular test table when the Test button is clicked. For each row of data in a test table, Slim sets its inputs using stter methods, and then calls the specified output methods.

Can we create test suite in FitNesse?

Yes, it is possible to create a suite within another suite page following the recursive approach. A static page if added on the suite page won't be executed as a FitNesse test.


3 Answers

It seems that Slim implies an empty string as an ignore, at least for the QueryTable fixture: A cell that is left blank in the table will be filled in from the result and counted as ignored.

Even though this is not considered a good solution, if you really have to you could use a regular expression to test on an empty string by matching on

=~/^$/

Another option is using the null fixture driver, as seen in http://fitnesse.org/FitNesse.SuiteAcceptanceTests.SuiteSlimTests.SlimSymbolsCanBeBlankOrNull

like image 98
bneijt Avatar answered Oct 10 '22 16:10

bneijt


passing the word 'blank' simulates a empty string.

like:

|Check|That the returned string is | blank |

like image 28
ryber Avatar answered Oct 10 '22 16:10

ryber


In this case - when you need to check with SLIM usage, whether the result is an empty string, you can use markup variable. Just define it somewhere on your page with test, like:

!define blank {}

And then call it anywhere you want:

|check|SomeFixtureName|${blank}|

like image 41
Kanstantsin Rybin Avatar answered Oct 10 '22 16:10

Kanstantsin Rybin