2

I'm using FitNesse to do some testing with Fixtures written in C#. One of my fixtures kicks off some testing suites to run in Ab Initio in a Unix environment. I would like to be able to kill the whole test suite if one of the tests within it fail. I imagine I would need some kind of return value from the test suite (on the unix box) and then that would get passed back up to my fixture which would kill FitNesse (from within my C# fixture). This is what my KickOff() method looks like right now:

public string KickOff()
{
    var data = new Dictionary<string, string>();
    foreach (var row in System.IO.File.ReadAllLines(unixConfigFile))
        data.Add(row.Split('=')[0], String.Join("=", row.Split('=').Skip(1).ToArray()));

    string server = data["servername"];
    string userId = data["username"];
    string password = data["password"];

    StringEncryptor3DES encryptor = new StringEncryptor3DES("fitnesse");
    password = encryptor.Decrypt(password);            

    UnixScriptRunner runner = new UnixScriptRunner(server, userId, password, unixPath, scriptName,EtlType.AbInitio);


    return runner.Run() & EtlStatus.IsEtlSuccessful(runner.LogFile,EtlType.AbInitio) ? "True":"False";
}

I think I need something that catches the value of EtlStatus.IsEtlSuccessful(), if it is false it will terminte FitNesse. The two questions I have are this:

Is this reasoning correct?

What is the code needed to terminite/kill FitNesse (or end the test suite if there is a more graceful way)?

Edit: I did a little more research and it looks like it is the 'runner' that I have to kill. Still not sure how to do this though...

intA
  • 2,513
  • 12
  • 41
  • 66

1 Answers1

2

If you're using Slim, you can throw an exception with "StopTest" in the class name to stop the test.

http://www.fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.SliM.ExceptionHandling

If you're using Fit, you can throw an AbandonStoryTestExecption to stop the test.

http://fitsharp.github.io/Fit/AbandonStoryTest.html

There's a new Fit feature coming in the next release (any day now!) to throw AbandonTestSuiteException to stop the entire test suite. There's no comparable feature with Slim AFAIK.

Mike Stockdale
  • 5,256
  • 3
  • 29
  • 33
  • So are you saying currently there is no way to stop the entire test suite? Just the current test? Wouldn't that test already be done if it has failed? – intA May 09 '14 at 12:54
  • If a test step (table) fails, by default, the remaining steps will be run. If you throw the appropriate exception, FitNesse will not try to run the remaining steps. – Mike Stockdale May 09 '14 at 16:29
  • Currently no built-in way to stop the entire suite. – Mike Stockdale May 09 '14 at 16:32
  • So, do you think this is impossible to do from within the fixture? Is there some workaround? Would it have to be done on the executing server? (In my case the unix server where Ab Initio lives) – intA May 12 '14 at 20:18
  • When the failure is detected, you could persist a 'stop test' flag somewhere and throw the 'StopTest' exception. In SetUp of each test, check the 'stop test' flag and throw 'StopTest' if set. This will run the entire suite but every test after the failure will immediately end. – Mike Stockdale May 12 '14 at 22:25