Search code examples
testingfitnessefitsharp

FitNesse: Test that an element is not in a list?


I'm using FitSharp to test an application and have a question related to testing contents of lists. Testing that an element is present in a list is simple to do using, for example, a SubsetFixture and could be written as this:

| Check that element is in list |
| 5 |

But is there a way to write a fixture that tests if an element is not in a list?

| Check that element is not in list |
| 5 |

I want the last table to pass only if 5 is not in the processed list.


Solution

  • The closest you can come with any kind of list fixture would be to use a array or set fixture and to list ALL of the items you DO expect. There is no "not one of these" list fixtures.

    I would recommend you just do a do fixture in one like like:

    |check|that element | 5 |  is in the list | False |
    

    or you could use a column fixture to get the feel for a set fixture

    | Check that element is not in list |
    | element | exists? |
    | 5 | false |