gpt4 book ai didi

junit - 我们可以在使用mule的org.mule.tck.FunctionalTestCase时使用JUnit注解吗?

转载 作者:行者123 更新时间:2023-12-01 07:47:53 26 4
gpt4 key购买 nike

我们使用 org.mule.tck.FunctionalTestCase 作为测试用例。它是一个抽象的 JUnit 测试用例。

这是在 pom.xml 中声明依赖项的方式:

    ...
<dependency>
<groupId>org.mule.tests</groupId>
<artifactId>mule-tests-functional</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
...

这是测试代码的样子:

import org.junit.Before;
import org.mule.tck.FunctionalTestCase;

public class SomeSuiteTest extends FunctionalTestCase {

protected String getConfigResources() {
return "my-mule-config.xml";
}

@Before
public void doStuff() {
...
}

public void testThisCode() throws Exception {
...
}
}

问题是永远不会调用 doStuff()。我的理解是@Before注解的方法是在每次测试之前调用的。此外,@Test 注释不是插件的一部分。看来我还需要从 org.junit 导入它,但我不相信它受支持。

我们可以在使用 org.mule.tck.FunctionalTestCase 时使用 JUnit 注解吗?

---更新---

我发现 FunctionalTestCase 的父类 AbstractMuleTestCase 有一个名为 doSetUp() 的方法,我可以在我的测试中覆盖它。就像 @Before 方法一样,它在每次测试之前被调用。我仍然更喜欢注释,因为 JUnit 文档中没有概述 doSetUp()。

最佳答案

如果你扩展 org.mule.tck.FunctionalTestCase 类,你必须遵守它的规则,即。覆盖 doSetUp()。请注意,doSetUp() 未在 JUnit 文档中概述,因为它特定于 FunctionalTestCase。

否则,扩展 org.mule.tck.junit4.FunctionalTestCase,这是 Junit4 友好的。

关于junit - 我们可以在使用mule的org.mule.tck.FunctionalTestCase时使用JUnit注解吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8276197/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com