如何将目标jar添加为同一个项目的测试资源?
我正在开发 Solr 插件 并使用 Solr 测试框架 我在 test/resources
下放置了一个测试 SOLR_HOME
目录code> 与 /conf/
和 /lib
。现在,框架实例化 SolrCore
并从 /lib
加载我的插件。将插件的 jar 输出到 /lib
不是问题,但问题是插件尚不可用,因为它仍然需要通过测试(先有鸡还是先有蛋)。
您建议如何解决这个问题?我看到这些选项:
创建另一个项目用于测试并依赖于插件,并在其中运行测试。很简单,但是我如何确保每次构建插件时也构建其他项目的测试?每次构建时自动化测试的要点是拥有一个新的插件 jar 来破坏测试。
在 dp4j pom.xml 中,我构建该项目分两个阶段,在第一个阶段我
仅注释处理器,而在另一个阶段我编译依赖于早期阶段编译的注释处理器的测试。< /p>
我赞成 2,因为复制粘贴配置似乎不是一个坏选择,并且使它看起来不像实际情况那么复杂。我不记得我是否在这里问过这个问题 - 你有什么建议?还有其他案例研究/工作代码可供查看吗?
I'm developing a Solr plugin and using the Solr test-framework I place a test SOLR_HOME
dir under test/resources
with /conf/
and /lib
. Now the framework inistantiates a SolrCore
and loads my plugin from /lib
. Not an issue to output the jar of the plugin to /lib
, but the issue is that the plugin is not yet available since it still needs to past the test (chicken and the egg).
How do you recommend solving this? I see those options:
Create another project for the tests with a dependency on the plugin, and in it run the tests. Simple enough, but how do I ensure that everytime the plugin is built also the tests of this other project is built? The point of the automated tests at every build is to having a new plugin jar which breaks the tests.
In dp4j pom.xml I build the project on 2 phases, in the 1st I
<include>
only the annotation processors while in the other I compile the tests which rely on the annotation processors compiled in the eariler phase.
I'm in favor of 2 since copy-pasting the configuration doesn't seem a bad option, and makes it seem less complicated than it probably is. I don't remember if I had asked about it here - what do you recommend? Any other case studies /working code to look at?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
还有第三个。最有可能是最好的解决方案〜什么也不做!
我的印象是 Solr Testframework 需要从
/lib
加载我的插件,但显然不需要,它可以从test-classes
加载它,所有靠它自己!there's a 3rd. most probably best solution ~ do nothing!
I was under the impression that the Solr Testframework need to load my plugin from
/lib
but apparently it doesn't need to, it can load it fromtest-classes
, all on its own!