简体   繁体   English

如果我的Java测试资源比较大(超过100MB),应该放在哪里?

[英]Where should I place my java test resources if they're relatively large (over 100MB)?

I'm working on a project with a maven structure and I want to begin doing some extended tests, but I'll need to a large amount of resources do to so. 我正在开发一个具有Maven结构的项目,我想开始进行一些扩展测试,但是这样做需要大量资源。 Any recommendations where I should place these resources? 有什么建议可以放置这些资源? Should they go into 'src/main/test/resources' or be pulled from a different repo or something else? 他们应该进入``src / main / test / resources''还是从其他仓库中取出?

Recapping your question 重新回答您的问题

Any recommendations where I should place these resources? 有什么建议可以放置这些资源? [...] [...]

I'm aware that I can place them in 'src/main/test/resources' [...] 我知道我可以将它们放在'src / main / test / resources'[...]

I'm thinking more of resources for integration tests. 我正在考虑将更多资源用于集成测试。 Developers won't necessarily want to pull a 100's of megs of resources from version control for tests they likely won't run. 开发人员不一定要从版本控制中提取100兆的资源来进行可能无法运行的测试。

Answer 回答

You might change to a multi-module project layout, something like: 您可能会更改为多模块项目布局,例如:

      multi-module project
              |
              |
          +---+-----------------+ 
          |                     |
source and unit test    integration test
         prj                   prj

then your developers could pull only source and unit test prj . 那么您的开发人员就只能拉source and unit test prj

Clearly integration test prj should have a compile scoped dependency on source and unit test prj . 显然,集成测试prj应该对source and unit test prj具有编译范围的依赖性。

Maven has an answer for you... Maven为您提供了答案。

If you include the resources inside the 'src/main/test/resources' (that's correct)... 如果您将资源包括在“ src / main / test / resources”中(是正确的)...

Remember that running an install in the final jar the tests will be excluded, and yes! 请记住,在最终的jar中运行安装将排除测试,是的! The resources are excluded too... 资源也被排除在外...

Moreover you could skipping tests (also the compilation) to improve compilation performance... (more info at: http://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-test.html ) 此外,您可以跳过测试(也包括编译)以提高编译性能...(更多信息,请访问: http : //maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-test.html

I hope this helps you... 我希望这可以帮助你...

UPDATE: 更新:

also give a look at " How can you display the Maven dependency tree for the *plugins* in your project? " 还看一看“ 如何在项目中显示* plugins *的Maven依赖树?

We should think about the reasons for excluding resources from the environment of the developer. 我们应该考虑将资源从开发人员环境中排除的原因。 I just answer your question telling the common practice of handling situations like yours by Maven... 我只是回答您的问题,告诉您Maven处理类似情况的常见做法...

If as you say it is actually a problem for you, it may be an idea, for example, to separate all the tests and resources inside another moduel...including that in your parent pom... Or maybe to define a profile (integration test) which will contains largely of test resources, and a profile (Developing test) that will only lead tests useful to the individual developer ... 如果您说这实际上对您来说是个问题,那么可能是一个主意,例如,将另一个模块中的所有测试和资源分离开来……包括您的父pom中的测试和资源……或者定义一个配置文件(集成测试),其中将主要包含测试资源,以及一个配置文件(开发测试),该配置文件仅会引导对单个开发人员有用的测试...

I personally think that unless there are special reasons (critical), beyond simply the amount of mega occupying test, you can safely proceed with all the resources in the test package... 我个人认为,除非有特殊原因(紧急),否则不仅可以进行大量的占用测试,还可以安全地进行测试包中的所有资源...

You should run this kind of large integration tests on a CI server, not on developer machines. 您应该在CI服务器上而不是在开发人员计算机上运行这种大型集成测试。

It's good practice to run long-running integration tests on a different machine to reduce the dev-test cycle time. 最好在另一台机器上运行长时间的集成测试,以减少开发测试的周期。 You wouldn't want to run that in your normal builds anyway, make a profile and run it on CI. 无论如何,您都不想在常规版本中运行它,创建一个配置文件并在CI上运行它。

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

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