我在蚂蚁中运行junit target时出现以下错误代码。 EshopCoreTestSuite是一个框架,如下所示:

public class EshopCoreTestSuite extends TestSuite {

    public static Test suite() {
        TestSuite suite = new TestSuite();
        suite.addTestSuite(CustomerContextTest.class);
        return suite;
    }
    public static void main(String[] args) {
         TestRunner.run(EshopCoreTestSuite.class);}  }


错误:

   <error message="com.bgc.EshopCoreTestSuite" type="java.lang.ClassNotFoundException">java.lang.ClassNotFoundException: com.bgc.EshopCoreTestSuite         ....
        </error>


junit目标:

<property name="COMP_TEST_SRC_DIR" location="test/java"/>
<property name="TEST_BUILD_DIR" location="build/test"/>
<property name="COMP_JAVA_SRC" location="src/java" />
<property name="COMP_BUILD" location="build" />


我只是在这里迷路。我有src文件夹,并且在此Java和test文件夹下有Java和测试文件。我希望我给出了更多/错误的途径。
....

<junit printsummary="on" fork="on">
        <classpath>
        <path refid="CLASSPATH_JUNIT"/>
        <dirset dir="${TEST_SRC_DIR}"/>
        </classpath>
        <env key="app.module" path="ESW"/>
        <env key="app.env" path="DEV"/>
        <test name="com.bgc.EshopCoreTestSuite" todir="../../../BUILD/ESW/ESWBUILD/CI/REPORT" outfile="junit_report">
        <formatter type="xml"/>
        </test>
    </junit>

最佳答案

尝试更改:

 <dirset dir="${TEST_SRC_DIR}"/>


至:

 <dirset dir="${TEST_BUILD_DIR}"/>


在该<junit>部分中。类路径必须包含内置类,而不是源文件。如果将您的类生成为.../src/java,请改用${COMP_JAVA_SRC}。 (但这有点不规范。)

关键是该dirset变量必须指向.class文件所在的根。

08-18 09:41
查看更多