简体   繁体   English

Fitnesse可以对套件中的每个测试使用新的过程吗

[英]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). 我们经常进行Fitnesse测试,这些测试会分别通过,但是作为套件的一部分运行时会失败(反之亦然)。

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. 有没有一种方法可以告诉Fitnessit在运行每个测试之前使用新的线程/进程/其他方法,从而确保在两种情况下测试的行为均相同。

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. 目前,我们在持续集成服务器中使用Suite结果,这意味着可以单独失败的测试可以进入我们的发行版。 This is making us nervous! 这让我们感到紧张!

In the example below, an AlarmDefintionSet is the parent object of an AlarmDefinition. 在下面的示例中,AlarmDefintionSet是AlarmDefinition的父对象。 The AlarmDefinitionSetSetUpFixture creates an AlarmDefinitionSet and stores it in memory. AlarmDefinitionSetSetUpFixture创建一个AlarmDefinitionSet并将其存储在内存中。 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. AlarmDefinitionFixture查找内存中的父级(可以是一个id,但是在下面的示例中,它使用的是默认值),将其设置为属性,然后设置Code,InitialWTGStopped和RunAlarm属性。 It then calls the Valid and ValidationMessage methods as the test. 然后,它调用Valid和ValidationMessage方法作为测试。

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. 但是,如果我要删除AlarmDefinitionSetSetUpFixture,则它在单独运行时会失败,因为它找不到合适的父级。 However, if it was run as part of a suite, and an earlier test had included an AlarmDefinitionSetSetUpFixture, then it would pass. 但是,如果它作为套件的一部分运行,并且较早的测试已包含AlarmDefinitionSetSetUpFixture,则它将通过。 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. 我可以使用Fitnesse的“ [SuiteName] .SetUpFixture”文件来调用清除内存中所有内容的方法,我们确实可以这样做。 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. 将这样的文件添加到我们的所有套件中将需要大量工作,并且还要确保它调用的方法正确地从内存中删除所有内容。

健身度测试示例

The fixtures in this example are all fit.ColumnFixture's 本例中的灯具都适合.ColumnFixture的

Thanks ... 谢谢 ...

Short answer - no there is not a FitNesse setting to make each test independent. 简短答案-否,没有FitNesse设置可以使每个测试独立进行。 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. 有时,我使用一个SetUp页面(该页面包含在每个测试页面的开头)来执行一项固定工作,以确保我为每个测试都拥有一个干净的环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM