简体   繁体   English

为什么我无法在travis或Circle CI环境上获得测试资源?

[英]Why can't I get a test resources on travis or circle CI environments?

I'm facing a very annoying issue while trying to run my project's junit tests inside a remote CI environment. 尝试在远程CI环境中运行项目的junit测试时,我面临一个非常烦人的问题。

In my local machine with java 1.8.0_181 and maven 3.5.4 I don't have any problem. 在使用Java 1.8.0_181和Maven 3.5.4的本地计算机中,我没有任何问题。

I used to use the two ways bellow to get a test resource: 我曾经使用以下两种方法来获取测试资源:

        String expected = Utils.readStream(new FileInputStream(
            "src/test/resources/testdata/fragment-subdir-absolute-path.txt"));

Using this I'm getting a file not found: 使用此我找不到文件:

java.io.FileNotFoundException: fragment-subdir-absolute-path.txt (No such file or directory) java.io.FileNotFoundException:fragment-subdir-absolute-path.txt(无此类文件或目录)

And with this: 并与此:

        String expected = Utils.readStream(new FileInputStream(getClass()
            .getResource("/testdata/fragment-subdir-absolute-path.txt")
            .getPath()));

In this case I'm getting a NPE: 在这种情况下,我得到了NPE:

[ERROR] testFragmentFragmentHost Time elapsed: 0.03 s <<< ERROR! [错误] testFragmentFragmentHost经过的时间:0.03 s <<<错误! java.lang.NullPointerException at org.osgi.service.indexer.impl.IndexerUnitTest.assertFragmentMatch(IndexerUnitTest.java:58) at org.osgi.service.indexer.impl.IndexerUnitTest.assertFragmentMatch(IndexerUnitTest.java:71) at org.osgi.service.indexer.impl.IndexerUnitTest.testFragmentFragmentHost(IndexerUnitTest.java:205) org.org.osgi.service.indexer.impl.IndexerUnitTest.assertFragmentMatch(IndexerUnitTest.java:71)上的org.osgi.service.indexer.impl.IndexerUnitTest.assertFragmentMatch(IndexerUnitTest.java:58)处的java.lang.NullPointerException osgi.service.indexer.impl.IndexerUnitTest.testFragmentFragmentHost(IndexerUnitTest.java:205)

But anyone is working inside of the remote CIs. 但是任何人都在远程配置项内部工作。 The file is not being found. 找不到文件。

Well, embarrassingly, after many many hours, I found where the issue was... :) 好,令人尴尬的是,经过许多小时,我发现问题出在哪里... :)

The culprit was a copied .gitignore file that contained this: 罪魁祸首是复制的.gitignore文件,其中包含以下内容:

# Package Files #
 target
 *.jar
 *.txt

Eclipse IDE adds a small interrogation icon on the uncommited files, a small repo icon to the committed ones and just remove the icon from the ignored ones. Eclipse IDE在未提交的文件上添加了一个小的询问图标,在已提交的文件上添加了一个小的repo图标,只是从被忽略的文件中删除了该图标。 I just didn't pay attention to those ignored ones. 我只是不注意那些被忽略的东西。

So, I changed that file to: 因此,我将该文件更改为:

# Package Files #
target/*.jar
target/*.txt 

and the mysterious unit tests errors have gone. 神秘的单元测试错误消失了。

thank all for the time... 感谢所有的时间...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM