2011-11-26 81 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友好。

相關問題