owenG
home learn tableau about
divider
SDLC VS 2010 Coded UI Test Coded UI Test and Fitnesse MSBuild 4.0 MSBuild and IronPython MSBuild and IronPython - TFS checkins MSBuild and IronPython - Custom SQL Data








previous next

Coded UI Test and Fitnesse Part 2

Filling out Fitnesse

Back to StringManipulationTest Fitnesse page, click Edit button on left-hand menu and replace the dll path and namespace placeholders with proper values for this environment:

wiki
    !contents -R2 -g -p -f -h
    !define TEST_SYSTEM {slim}
    !define COMMAND_PATTERN {%m -r fitSharp.Slim.Service.Runner,slim1.6\fitsharp.dll %p}
    !define TEST_RUNNER {slim1.6\Runner.exe}
    !path C:\owenG\projects\FitnesseTestHarness\FitnesseStringTests\bin\Debug\FitnesseStringTests.dll

    |import|
    |fitsharpStringTests| 

Skip a couple of lines and add three more lines:

wiki
    !|StringManipulatorTests|
    |First Piece Of Text|Second Piece Of Text|Join Text Together?|
    |Hello|World|HelloWorld| 
    Where we have now created a test table:
  1. First line contains the class name, delimited by the pipe character before and after. Parameters can be passed in via a second column on than same line e.g. "!|StringManipulatorTests|ctorArgument|"
  2. Second line has three columns for now
    • the header that will match up with SetFirstPieceOfText method
    • the header that will match up with SetSecondPieceOfText method
    • the function to be tested, in this case JoinTextTogether
  3. Final line represents a single row of data, with the first two values being manipulated via JoinTextTogether, followed by a comparison on the method's return value vs. the third data point here, "HelloWorld" text

This particular type of tables is called a Decision Table but there are several more types, see http://fitnesse.org/FitNesse.UserGuide.SliM and http://schuchert.wikispaces.com/FitNesse.Tutorials.CSharp.Slim.EachTable for more info on the other table definitions.

Regarding test table syntax:
- The camel casing of text and how it relates to the existing wiki syntax can get a little tricky. The namespace was fine as-is- although it was camel cased the name began with a lower-case letter. If the line for the class name had simply read "|StringManipulatorTests|" though, the test would have failed due to the upper camel casing. Assuming we wanted to keep that exact class name, the alternatives would be to enter either add space separators: "|String Manipulator Tests|" or, as I did above, precede the line with an exclamation point character. This latter formatting choice indicates to Fitnesse that wiki-specific syntax should be ignored. Having that '!' character in the first line means that we also don't need to insert spaces when referencing the fitSharp methods/field headers in the wiki text. For them the spaces actually help out though for overall readability purposes.
- Any table element ending with a question mark (?) is understood to be a return method, as opposed to an input method/property

Test the Test, +/-

Now to see if this very simple test passes. Click Save button, just below the edit portion of the wiki page and the main test page should like like:

ready for first test

Click the Test       button and

first test pass passes

Success - Assertions: 2 right, 0 wrong, 0 ignored, 0 exceptions

2 asserted correctly, where one (in this version of fitSharp) was simply for finding the StringManipulatorTests class and the second for the real test. This latter test involved sending "hello" and "world" strings out to StringManipulatorTests.JoinTextTogether, getting the method's return value, and comparing it to the value stored in Fitnesse page ("helloworld").

Happy path ok, try a simple negative test by changing the last line in the test table by adding a space to the third column:

wiki
    |Hello|World|Hello World| 

Try Test       again ...

first test fails

As expected, the text returned by JoinTextTogether ("HelloWorld") does not match the expected value as defined in the wiki page, "Hello World".

Next step will be to complete the table, adding calls to the other two methods as well as more test data:

wiki
!|String Manipulator Tests|
|FirstPiece Of Text|Second Piece Of Text|Join Text Together?|SwapTextOrderAndJoin?|
    ReverseLettersInFirstPieceOfTextAndJoin?|
|Hello|World|HelloWorld|WorldHello|olleHWorld|
|New|York|NewYork|YorkNew|weNYork|
|apple|zebra|applezebra|zebraapple|elppazebra|

Run test again, everything passes. Leaving the world of Fitnesse for now, in order to set up the CUIT test.

previous next