1

How do I specify data to be used in each of my test cases?

i.e. I wish to use one table to setup some data and then run a bunch of tests against that data.

Thanks

Mike Stockdale
  • 5,256
  • 3
  • 29
  • 33
Stuart L
  • 31
  • 6

1 Answers1

0

I've been looking at Gojko and their suggestion is to create a singleton that you invoke at the beginning of your test page. Here's an example of the FitNesse edit:

!|import         |
|Demo1.Containers|
|Demo1.Fixtures  |

!|SUT         |
|Get Practice?|
|$practice=   |

And my C# code (SUT -> System Under Test is a basic Singleton:

public class SUT
{
    private static Practice _practice = null;
    public static Practice getPractice()
    {
        if (_practice == null)
        {
            _practice = new Practice();
        }
        return _practice;
    }
}

My other classes that I'm testing use that singleton to get their data.

    public class AddDoctorToPractice
    {
        private Practice practice = SUT.getPractice();
        ...

I hope that helps.

Queso
  • 967
  • 1
  • 12
  • 26