Search code examples
c#unit-testingcsvmbunitgallio

Skip unit test if csv file not found


I have a number of unit tests which rely on the presence of a csv file. They will throw an exception if this file doesn't exist obviously.

Are there any Gallio/MbUnit methods which can conditionally skip a test from running? I'm running Gallio 3.1 and using the CsvData attribute

[Test]
[Timeout(1800)]
[CsvData(FilePath = TestDataFolderPath + "TestData.csv", HasHeader = true)]
public static void CalculateShortfallSingleLifeTest()
{
    .
    .
    .

Thanks


Solution

  • According to the answer in this question, you'll need to make a new TestDecoratorAttribute that calls Assert.Inconclusive if the file is missing.

    Assert.Inconclusive is very appropriate for your situation because you aren't saying that the test passed or failed; you're just saying that it couldn't be executed in the current state.