Skip to content

Commit

Permalink
Add fixtures with parameters to the library
Browse files Browse the repository at this point in the history
Update of the documentation to show a nice feature of FitNesse: Add
fixtures with parameters to the library
  • Loading branch information
six42 committed Mar 28, 2015
1 parent 102b835 commit 244ffa7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
!|import |
|fitnesse.slim.test|

Create a fixture with constructor parameters.
You can do further set up by calling more methods of the fixture if required.
At the end assign the fixture itself to a symbol.

!|script|test query|2|
|show |query |
|$tq= |get fixture |

Negative Test: This must raise an exception as the method query can not be found
!|script|echo fixture |
|check |echo |AAA |AAA |
|#check |query|[[[n, 1], [2n, 2]], [[n, 2], [2n, 4]]]|

Now add the previously created fixture symbol to the library
|library|
|$tq |

And here we go: We can use the methods of the fixture in any script
!|script|echo fixture |
|check |echo |AAA |AAA |
|check |query|[[[n, 1], [2n, 2]], [[n, 2], [2n, 4]]]|
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<properties>
<Edit>true</Edit>
<Files>true</Files>
<LastModifyingUser>six42</LastModifyingUser>
<Properties>true</Properties>
<RecentChanges>true</RecentChanges>
<Refactor>true</Refactor>
<Search>true</Search>
<Test>true</Test>
<Versions>true</Versions>
<WhereUsed>true</WhereUsed>
</properties>
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ The order of method execution is as follows:
2. Find method on SystemUnderTest, if present execute
3. Find method on installed Library in '''reversed''' order of creation. So last one created takes precedence over the ones created earlier.


If you need to initialise the fixture you want to add to the library or your fixture has constructor parameters than this is possible as well.
See details on [[How To Add Fixtures With Paramerters To The Library][.FitNesse.SuiteAcceptanceTests.SuiteSlimTests.LibrarySuite.HowToAddFixturesWithParamertersToTheLibrary]]
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<properties>
<Edit>true</Edit>
<Files>true</Files>
<Properties>true</Properties>
<RecentChanges>true</RecentChanges>
<Refactor>true</Refactor>
<Search>true</Search>
<Versions>true</Versions>
<WhereUsed>true</WhereUsed>
<Edit/>
<Files/>
<LastModifyingUser>six42</LastModifyingUser>
<Properties/>
<RecentChanges/>
<Refactor/>
<Search/>
<Static/>
<Versions/>
<WhereUsed/>
</properties>

0 comments on commit 244ffa7

Please sign in to comment.