In this tutorial, we are going to discuss about slim tables present in FitNesse. These are:
- Import Table.
- Library Table.
- Comment Table.
Import Table
Import table is a simple slim table which adds a path to the Java code fixture search path. In other words, it informs the slim processor that the fixtures present on the current page could be present at the paths mentioned in the Import table.
To work with Import table, we need to do the following.
- Syntactically, Import table has the FitNesse reserved word “Import”. This word should be present in the first row and the first column of the table.
- It is a table with single column and multiple rows.
- After the first row, the following rows in the table have the Java qualified path where the actual fixtures may be located that are used on the current FitNesse page.
FitNesse Screenshot For Import Table:
As described above, Import table is a table with single column and multiple rows. First cell of the table has reserved word “Import” and the following cells have the Java qualified path for the Java fixtures as shown below.
Library Table
Library table is a table that installs available fixtures for all underneath FitNesse test pages wherever this table is called on those FitNesse pages. The first row in a table contains the word Library which informs the slim processor which table type to execute.
To work with Library table, we need to do the following.
- Syntactically, Library table has the FitNesse reserved word “Library”. This word should be present in the first row and the first column of the table.
- It is a table with single column and multiple rows.
- After the first row, the following rows in the table have the Java fixture class names where the actual get and set methods are defined that could be used on the current FitNesse page.
Library Table Example
Library table is useful, whenever a method is called that is not available on the fixture used on the current FitNesse page but present in other fixture which is defined in the library table. Slim processor will scan all the installed available libraries for that method and when found it will be invoked on the current FitNesse test page.
Below is the screenshot of the Java Fixture used as a script table on the current FitNesse test page.
Below is the screenshot of the Java Fixture that is defined inside the Library table, so that the methods present in the fixture can be used if they are not present in the current script table.
Explanation for Java Fixture:
- Fixture known as “LibraryTableMyFixture” is the fixture with the method “doBusinessLogicHere” that simply returns a string “Success”.
- Fixture known as “PrintScript” is the fixture with the method “print” that simply returns a string “Hello Fitnesse”.
FitNesse Screenshot for Library table:
- On the FitNesse test page, we are calling a library table in which we have defined fixture “print script” as shown below.
- Next on the page we are calling a script table “library table my fixture”. This fixture has a method known as “do business logic here” that returns a string “Success”. In the script table we can check for the value that this method returns. If the return value matches the expected output, that cell will be marked as green color otherwise red color on failure.
- Next row in the script table, we have mentioned a note which will be ignored by the slim processor.
- On the last row in the script table, we are calling a “print” method which is not present in the fixture “library table my fixture” but it is present in the fixture “PrintScript” that is defined in the Library table.
- When we will run the current FitNesse page setup. Second row where “do business logic here” method is checked against string “Success” will be marked as green as output matches the expected value.
- Slim processor will ignore the third row note as it is just a comment row in the script table.
- In the last row, we are checking for “print” method return value is not defined under fixture “library table my fixture”. Since the library table has the fixture “print script” defined therefore, slim processor will look for method “print” in the “print script” fixture and will check the return value against expected value. Here, in this case both value matches therefore, FitNesse has marked those cells as green as shown below.
Few Points to remember for Library table
There is an order of method execution when library table is used on the FitNesse page.
- It will first find a method on fixture; if present then it will be executed.
- If the above step is not fruitful then, it will find a method on System under Test; if present then it will be executed.
- If both above steps fail, then it will find a method on installed Library in reversed order of creation. So the last one created will take the precedence over the ones that were created earlier.
Comment Table
Comment table in FitNesse is the table that does absolutely nothing. The first row in a table contains the word “Comment” which informs the slim processor that this is a comment table and its processing should be ignored.
To work with Comment table, we need to do the following.
- Syntactically, Comment table has the FitNesse reserved word “Comment”. This word should be present in the first row and the first column of the table.
- It is a table that can have multiple rows and multiple columns following the first row and first column cell with “comment” keyword.
- This table is used when the explanation is required for the step by step test execution on the current FitNesse page.
FitNesse Screenshot for Library table:
On the below FitNesse screen, first row starts with the keyword “comment” informing the slim processor that it is a comment table and it does not requires the processing of the number of following rows with comments.
⇓ Subscribe Us ⇓
If you are not regular reader of this website then highly recommends you to Sign up for our free email newsletter!! Sign up just providing your email address below:
Happy Testing!!!