使用 mule 的 org.mule.tck.FunctionalTestCase 时可以使用 JUnit 注释吗?
我们使用 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() 。
We are using org.mule.tck.FunctionalTestCase for test cases. Its an abstract JUnit test case.
This is how the dependencies are declared in the 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>
...
This is what the test code looks like:
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 {
...
}
}
The problem is that doStuff() is never called. My understanding is that the method annotated by @Before is called before every test. Additionally, the @Test annotation is not part of the plug-in. It appears that I need to import that from org.junit as well, but I am not convinced it is supported.
Can we use JUnit annotations when using org.mule.tck.FunctionalTestCase?
--- Update ---
I found that a parent class of FunctionalTestCase, AbstractMuleTestCase, has a method titled doSetUp() that I can override in my test. Like an @Before method, it is called before every test. I would still prefer annotations since doSetUp() is not outlined in the JUnit documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你扩展 org.mule.tck.FunctionalTestCase 类,你必须遵守它的规则,即。重写 doSetUp()。请注意,JUnit 文档中没有概述 doSetUp(),因为它特定于FunctionalTestCase。
否则,扩展 org.mule.tck.junit4.FunctionalTestCase,这是 Junit4 友好的。
If you extend the org.mule.tck.FunctionalTestCase class, you have to play by its rules, ie. override doSetUp(). Note that doSetUp() is not outlined in the JUnit documentation because it is specific to FunctionalTestCase.
Otherwise, extend org.mule.tck.junit4.FunctionalTestCase, which is Junit4-friendly.