50 lines
3.4 KiB
Plaintext
50 lines
3.4 KiB
Plaintext
!1 Getting Test Tables Onto the Page
|
|
As we have seen FitNesse expresses AcceptanceTests as tables of '''input''' data and '''expected output''' data. (If you have not done so, you should probably check out the example table tutorial in the TwoMinuteExample. You should then check out the wiki page-editing tutorial on EditingFitNessePages.) Yet again, let's look at our test table for testing the division function of a calculator application:
|
|
|
|
!|eg.Division|
|
|
|numerator|denominator|quotient?|
|
|
|10 |2 |5 |
|
|
|12.6 |3 |4.2 |
|
|
|100 |4 |33 |
|
|
|
|
So how do we get this table on to the page? Well the [[wiki markup language][MarkupLanguageReference]] that defines the above table looks like this:{{{
|
|
|eg.Division|
|
|
|numerator|denominator|quotient?|
|
|
|10 |2 |5 |
|
|
|12.6 |3 |4.2 |
|
|
|100 |4 |33 | }}}
|
|
!3 Typing it In By Hand
|
|
We can pretty easily type in the above markup code for our Division table by hand in the page editing window. The vertical bars (!-|-!) delimit cells within rows. As long as you have the right number of vertical bars between data elements, FitNesse will correctly format your table for you. For small tables that will not change frequently, that's a perfectly reasonable way to do it.
|
|
!3 Using a Spreadsheet to Create Tables
|
|
Let's face it: a simple text-editing frame (such as the FitNesse edit frame) is not the best tool in the world for manipulating tabular representations of data. It's not especially easy to copy and paste rows or columns, move rows or collumns, etc. That's the sort of thing that spreadsheets are great at. When you work with lots of FitNesse tables, particularly large ones, it's great to be able to work in a spreadsheet like Excel to get the table just the way you want it, then copy it over to FitNesse, formatted properly using the wiki markup language. Fortunately, FitNesse makes this easy to do.
|
|
|
|
!3 Spreadsheet Example
|
|
Let's say that you have the ''Division'' table in Excel and you want to move it into !-FitNesse-!.
|
|
|
|
* Within Excel, select the table and copy it to the clipboard.
|
|
* Go to the !-FitNesse-! page where you want the table and ''Edit'' it (or create it).
|
|
* Paste the table into the edit pane. It will show up without any wiki markup formatting:
|
|
{{{
|
|
eg.Division
|
|
numerator denominator quotient?
|
|
10 2 5
|
|
12.6 3 4.2
|
|
100 4 33 }}}
|
|
* Now click the '''!-Spreadsheet to FitNesse-!''' button on the bottom of the page.
|
|
|
|
''Voila!'' FitNesse reformats the table (and any other table on the page) with the proper wiki markup delimiters:
|
|
{{{
|
|
!|eg.Division|
|
|
|numerator|denominator|quotient?|
|
|
|10|2|5|
|
|
|12.6|3|4.2|
|
|
|100|4|33| }}}
|
|
|
|
'''Note: This is best done one table at a time''', one page at a time. Furthermore, the table must have '''at least two columns'''. When you click the '''!-Spreadsheet to FitNesse-!''' button, FitNesse attempts to format everything on the page that '''might''' be a table.
|
|
|
|
!3 Copying Tables From FitNesse to the Spreadsheet
|
|
You can also take an existing FitNesse table, select it, and click the '''!-FitNesse to Spreadsheet-!''' button to get it back into non-wiki markup language format. You can then easily paste it back into the spreadsheet application.
|
|
|
|
!2 Learning More
|
|
If you are interested in the fixture code that makes it possible to run test tables, check out FixtureCode. If you want to learn what the different styles of test tables are and how to apply them, check out TestTableStyles.
|