Junit 使用蚂蚁

Junit using ant

我有一个 class 看起来像这样:

---imports---

class ErroringClass {

/* methods*/
main{}

}

更新

public class TestErroringClass {

static ArrayList<Integer> arrayTestTimes;
static ErroringClass main = new ErroringClass ();

@Test
public test{}

 .
 .
 .
}

测试用例:初始化错误耗时 0.002 秒 导致错误 class ErrorTestClass 不是 public。 java.lang.Exception: class ErrorTestClass 不是 public。 在 java.lang.reflect.Constructor.newInstance(Constructor.java:423)

测试用例:初始化错误耗时 0 秒 导致错误 测试 class 应该只有一个 public 构造函数 java.lang.Exception:测试 class 应该只有一个 public 构造函数 在 java.lang.reflect.Constructor.newInstance(Constructor.java:423)

<!-- Testsuite -->
<target name="test" depends="compile" >
    <junit fork="yes" 
           description="Unit Tests"
           showoutput="true"
           printsummary="true"
           outputtoformatters="true" filtertrace="on">
        <classpath>
            <path refid="classpath.test"/>
            <pathelement location="${main.build.dir}"/>
            <pathelement location="${test.build.dir}"/>
        </classpath>

        <test name="ErrorTestClass" outfile="./output" >
            <!-- <formatter type="brief" usefile="true" /> -->
            <formatter type="plain" usefile="true" />
        </test>
    </junit>
</target>

尝试 运行 我从 ant 进行测试,而不是让他们看到我在一个文件中的所有文件,以按照设计规则保持源代码可访问。我错过了什么?

已更新

Testsuite: ErrorTestClass
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.104 sec 
------------- Standard Output ---------------
[]
------------- ---------------- ---------------
Testcase: Test1 took 0.001 sec
Testcase: Test2 took 0 sec
Testcase: Test3 took 0 sec
Testcase: Test4 took 0 sec
Testcase: Test5 took 0 sec
Testcase: stringTestNull took 0.001 sec
Testcase: stringTestTrue took 0 sec
Testcase: assertNullTest took 0 sec

因为 ErrorTestClass 具有包级访问权限(默认可见性修饰符)。将其更改为 public class ErrorTestClass.