cedd
cedd

Reputation: 1853

Can Fitnesse use a new process for every test in a suite

We often have Fitnesse tests that pass individually but fail when run as part of a suite (or vice versa).

This is because some of the setup remains between each test. Is there a way to tell Fitnesse to use a new thread / process / whatever before running every test so that the tests were guaranteed to behave the same way in both cases.

At the moment we use the Suite results in our continuous integration server which means that tests which would fail individually can get through to our releases. This is making us nervous!

In the example below, an AlarmDefintionSet is the parent object of an AlarmDefinition. The AlarmDefinitionSetSetUpFixture creates an AlarmDefinitionSet and stores it in memory. The AlarmDefinitionFixture finds is parent in memory (this can be by an id, but in the example below it is using the default one), sets this as a property and then sets the Code, InitialWTGStopped and RunAlarm properties. It then calls the Valid and ValidationMessage methods as the test.

This test works fine when run as part of a suite or on its own. However, if I were to remove the AlarmDefinitionSetSetUpFixture it would then fail when run on its own, as it wouldn't be able to find a suitable parent. However, if it was run as part of a suite, and an earlier test had included an AlarmDefinitionSetSetUpFixture, then it would pass. This is a mild simplification but it illustrates the relevant points. I could use the Fitnesse "[SuiteName].SetUpFixture" file to call a method which clears everything out of memory, and we may indeed do this. It will be a lot of work adding such a file to all of our suites and also ensure that the methods it calls correctly remove everything from memory.

Example Fitnesse test

The fixtures in this example are all fit.ColumnFixture's

Thanks ...

Upvotes: 0

Views: 830

Answers (1)

Mike Stockdale
Mike Stockdale

Reputation: 5266

Short answer - no there is not a FitNesse setting to make each test independent. You need to take care of that yourself. Sometimes I use a SetUp page, which gets included at the start of each test page, to execute a fixture that makes sure I have a clean environment for each test.

Upvotes: 0

Related Questions