gpt4 book ai didi

ant - Ant 的 Junit 测试错误,没有消息,没有给出原因

转载 作者:行者123 更新时间:2023-12-05 06:47:01 27 4
gpt4 key购买 nike

我正在尝试对 ant 使用 Junit 测试。

因为我真的不知道如何在没有 eclipse 的情况下编写 Junit 测试,所以我将从我在网上找到的完全微不足道的东西开始。这应该总是通过。

测试1.java

import junit.framework.*;
public class Test1 extends TestCase {
@Test
public void testOne()
{
System.out.println("Heyy there I'm a test!");
assertTrue( "TestExample", true );
}
}

我将这些添加到我的 build.xml 中......

49   <target name="junit" depends="jar">
50 <junit printsummary="withOutAndErr" fork="yes" showoutput="yes">
51 <classpath refid="application"/>
52 <test name="test.Test1"/>
53 </junit>
54 </target>

所以现在当我运行“ant junit”时,我得到了

junit:
[junit] Running test.Test1
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

所以...这并没有告诉我任何...出了什么问题?如何解决?没有。有人知道怎么回事吗?

最佳答案

我可以复制它。我期待 junit 给出一些更详细的消息,比如 Class test.Test1 not found。但不,它只是失败了。这意味着该类不在类路径中。打开您的 jar 文件(使用 7zip 之类的存档器进行确认)。

毫不奇怪,因为您的类无法编译 :) 添加以下内容:

package test;
import org.junit.Test;

你的第一个测试应该通过了。

关于ant - Ant 的 Junit 测试错误,没有消息,没有给出原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12682278/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com