本文介绍了当使用m子的org.mule.tck.FunctionalTestCase时,我们可以使用JUnit批注吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将org.mule.tck.FunctionalTestCase用于测试用例.它是一个抽象的JUnit测试用例.

We are using org.mule.tck.FunctionalTestCase for test cases. Its an abstract JUnit test case.

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

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>
    ...

这是测试代码的样子:

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导入该文件,但我不确信它是否受支持.

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.

使用org.mule.tck.FunctionalTestCase时可以使用JUnit批注吗?

Can we use JUnit annotations when using org.mule.tck.FunctionalTestCase?

-更新---

我发现FunctionalTestCase的父类AbstractMuleTestCase具有名为doS​​etUp()的方法,可以在测试中覆盖该方法.就像@Before方法一样,它在每次测试之前都被调用.我仍然希望使用批注,因为JUnit文档中未概述doSetUp().

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.

推荐答案

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

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.

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

Otherwise, extend org.mule.tck.junit4.FunctionalTestCase, which is Junit4-friendly.

这篇关于当使用m子的org.mule.tck.FunctionalTestCase时,我们可以使用JUnit批注吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 18:21