我们对测试用例使用org.mule.tck.FunctionalTestCase。它是一个抽象的JUnit测试用例。使用mule的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方法一样,它在每次测试之前都会调用。我仍然更喜欢注释,因为doSetUp()没有在JUnit文档中列出。