gpt4 book ai didi

java - Buildr - 将测试资源放在类路径上

转载 作者:行者123 更新时间:2023-12-02 00:28:10 35 4
gpt4 key购买 nike

我正在尝试使用buildr构建我的 Java 项目。我有一堆协和测试和 HTML 规范,位置如下:

src/test/java/spec/x/y/z/SomethingTest.java
src/test/resources/spec/x/y/z/Something.html

buildr找到实际的测试代码 ( SomethingTest.java ) 并运行它,但 HTML 并未最终出现在类路径中,因此测试失败。我收到以下错误:

[junit] Testcase: [Concordion Specification for 'Something'] took 0.002 sec
[junit] Caused an ERROR
[junit] Resource '[classpath: /x/y/z/Something.html]' not found
[junit] java.io.IOException: Resource '[classpath: /x/y/z/Something.html]' not found
[junit] at org.concordion.internal.ClassPathSource.createInputStream(ClassPathSource.java:15)
[junit] at org.concordion.internal.XMLSpecificationReader.readSpecification(XMLSpecificationReader.java:25)
[junit] at org.concordion.Concordion.process(Concordion.java:30)
[junit] at org.concordion.Concordion.process(Concordion.java:26)
[junit] at org.concordion.internal.FixtureRunner.run(FixtureRunner.java:18)
[junit] at org.concordion.integration.junit4.ConcordionRunner$1.evaluate(ConcordionRunner.java:113)
[junit] at org.concordion.integration.junit4.ConcordionRunner.runChild(ConcordionRunner.java:104)
[junit] at org.concordion.integration.junit4.ConcordionRunner.runChild(ConcordionRunner.java:18)
[junit]
[junit] TEST x.y.z.SomethingTest FAILED

我的buildfile如下:

repositories.remote = 'http://www.ibiblio.org/maven2'

JODA = 'joda-time:joda-time:jar:2.0'
CONCORDION = 'org.concordion:concordion:jar:1.4.2'
XERCES = 'xerces:xercesImpl:jar:2.8.1'
XOM = 'xom:xom:jar:1.2.5'

define 'my-project' do
project.version = '0.0.1'
compile.with JODA
test.with XERCES, XOM, CONCORDION
package :jar
end

我尝试使用 Java.classpath << 'src/test/resources/x/y/z' 上的变体将 HTML 文件强制放入类路径中。和test.resources.include但无济于事。我确信我只是错过了一些简单的事情。任何帮助将不胜感激。

最佳答案

默认情况下,Buildr 使用 Maven 约定来分离源代码和资源。所以测试资源需要放到“src/test/resources”目录下。

关于java - Buildr - 将测试资源放在类路径上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9647621/

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