0

I have a Number of tests. Each test contains different commands verify() and command(). The order and number of times I need to check these vary though depending on the test. How can I structure this in a convenient way. I have been playing with Suites and Categories but can´t find a good solution. in the JUNIT GUI I would like to see the Testname and bellow it the teststeps command or verify. Any ideas?

4

1 回答 1

2

我发现使用 maven 和现代 IDE,测试套件的用处并不那么明显。

默认情况下,Maven 将运行您的所有测试;并且任何 IDE 都将允许您运行所有测试或选择要运行的测试,例如,按包。我通常发现在不同的包中创建测试类是我每个人真正使用的所有组织。

让我担心的是,您说需要测试的“顺序和次数”会有所不同。我不清楚你的意思是什么,但如果你的意思是为了通过测试,它取决于其他测试执行的顺序(和时间),那么你需要重新构建你的测试。(特别是在单元测试的情况下。)

任何测试都不应该依赖于另一个测试。执行顺序没有保证,在不同的环境中执行的顺序可能不同,甚至可以并行执行。

查看@Before、@After、@BeforeClass、@AfterClass ( http://junit.sourceforge.net/doc/faq/faq.htm#organize_3 ) 以获取有关测试初始化​​的更多信息。不过,我不确定这是否可以解决您的问题。

于 2013-04-15T14:47:59.077 回答