2011-11-26 84 views
3

我们对测试用例使用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文档中列出。

回答

4

如果扩展org.mule.tck.FunctionalTestCase类,则必须按其规则进行操作,即。覆盖doSetUp()。请注意,doSetUp()在JUnit文档中没有列出,因为它特定于FunctionalTestCase。

否则,请扩展org.mule.tck.junit4.FunctionalTestCase,它对Junit4友好。

相关问题