简体   繁体   English

Fitnesse:如何初始化/ tearDown套件(不是单独的测试)

[英]Fitnesse: how to initialize/tearDown suite (not individual test)

I have a basic question: 我有一个基本问题:

When using JUnit, in your test suite (the class that holds your tests) you can declare suite-level initialization and cleanUp behaviour using @BeforeClass and @AfterClass. 在使用JUnit时,在测试套件(包含测试的类)中,您可以使用@BeforeClass和@AfterClass声明套件级初始化和cleanUp行为。 The methods thusly annotated are called before the suite begins and after the suite finishes all its tests respectivelly. 这样注释的方法在套件开始之前和套件完成其所有测试之后被调用。 This differs from the methods inside the suite which are annotated with @Before and @After which are called before each test is launched and after each finishes respectivelly. 这与套件内部的方法不同,后者使用@Before和@After进行注释,在每次测试启动之前和每次测试完成之后调用它们。

I want the same setup in Fitnesse. 我希望在Fitnesse中使用相同的设置。 I found out how to have stuff that's executed before and after each test (you create a SetUp page and a TearDown page in the suite, and they'll be called before and after each test in the suite). 我发现了如何在每次测试之前和之后执行的操作(在套件中创建一个SetUp页面和一个TearDown页面,它们将在套件中的每个测试之前和之后调用)。 These are the equivalent of @Before and @After in JUnit. 这些相当于JUnit中的@ Before和@After。 I can't however understand how can I declare a suite-level initialization and cleanUp logic (like @BeforeClass and @AfterClass in JUnit). 但我无法理解如何声明套件级初始化和cleanUp逻辑(如JUnit中的@BeforeClass和@AfterClass)。 Can someone please tell me if/how this can be achieved? 有人可以告诉我是否/如何实现这一目标?

What I've tried is have a parent suite with SetUp and TearDown pages, and INSIDE that parent suite have mutlipl child suites which contain the actual tests (each with it's own SetUp and TearDown), hoping that this way the parent suite SetUp and TearDown pages will be called before and after each child suite, and the child suite's SetUp and TearDown pages will be called before and after each test in the suite, but no dice, what happends here is that the child suite SetUp/TearDown overrides the parent suite ones. 我试过的是有一个带有SetUp和TearDown页面的父套件,INSIDE那个父套件有mutlipl子套件,里面包含实际的测试(每个套件都有自己的SetUp和TearDown),希望通过这种方式设置父套件SetUp和TearDown页面将在每个子套件之前和之后调用,子套件的SetUp和TearDown页面将在套件中的每个测试之前和之后调用,但没有骰子,这里发生的是子套件SetUp / TearDown覆盖父套件那些。

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

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