English 中文(简体)
模块问题之间分享试验资源
原标题:Sharing test resourcing between modules issue

我想分享2个单元A和B之间的测试资源。 和

-dir
----f1
----f2

页: 1 maven项目之间共享测试资源。 如今,从B测试开始,我可以利用 like类资源:

 this.getClass().getClassLoader().getResource("dir/f1")

并且完全是罚款。 但是,我不想重记所有档案名称,例如<代码>f1或f2。 我真正想要的是从目录中获取所有档案。 和

 File foo = new File(this.getClass().getClassLoader().getResource("dir").getFile());
 assert foo.isDirectory()
 foo.list()
 ...

但是,当我以这种方式制造oo时,它就存在(foo.exist()。

我如何处理这个问题?

<>Update. Alternative Solutions using ant

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.5</version>
    <executions>
        <execution>
            <configuration>
                <target>
                    <fileset id="d" dir="${basedir}/src/test/resources/dir" includes="*"/>
                    <pathconvert property="d" refid="d">
                        <map from="${basedir}/src/test/resources/" to=""/>
                    </pathconvert>
                    <touch file="${basedir}/src/test/resources/d/listOfCharts.txt"/>
                    <echo file="${basedir}/src/test/resources/d/listOfCharts.txt" message="${charts}"/>
                </target>
            </configuration>
            <phase>package</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>
最佳回答

你谈到的办法是设立一个联合调查组,可在以后的测试中使用。 您可以这样列出口头的内容。 你们需要使用Jar, 你们需要把它看作是特别的Jar。

我如何将档案列入JAR档案?

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签