谷歌应用引擎 + GWT + Eclipse:你的单元测试在哪里?
我刚刚开始一个结合了 GWT、Google App Engine 和 Google Eclipse 插件的项目。 存储我的测试的最佳位置在哪里? 我通常使用 src/main/java 来组织 Maven 风格的代码,并在 src/test/java 中进行测试。 我从插件获得的默认设置将我的源代码直接转储到 src 中,我不太喜欢这种方式,但我不想与这些工具作斗争。 在这样的项目中进行单元测试的“标准”位置是什么?
解决方案:
- 创建
src/main/java
,将现有代码移到那里 - 创建
src/test/java
,在此处添加您的测试 - 转到项目-> 属性-> Java 构建路径,将新位置添加为源文件夹。
I'm just getting started with a project that combines GWT, Google App Engine and the Google Eclipse plugin. Where is the best place to store my tests? I normally keep my code organized Maven-style, with src/main/java
, and tests in src/test/java
. The default setup I get from the plugin dumped my source directly into src
, which I'm not too fond of, but I'd prefer not to fight against the tools. What's the "standard" place to put unit tests in such a project?
Solution:
- create
src/main/java
, move the existing code under there - create
src/test/java
, add your tests here - go to Project -> Properties -> Java Build Path, add the new locations as Source Folders.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了 GAE 测试的一种问题:某些测试需要 appengine-testing.jar ,它与项目的主 appengine-api-xxx.jar 冲突。 这样,我就能够运行 GAE 测试,但它与正常的运行/调试启动发生冲突。 为了能够在本地计算机上运行该应用程序,我必须删除 appengine-testing.jar,然后,我的测试/类中出现了很多编译错误。
如果您需要建议,请在另一个项目中设置您的测试类(您可以在其中使用罐子而不会发生冲突)
否则,如果您让它工作,请告诉我您是怎么做的。
多谢。
I've faced a kind of problem woth GAE testing: Some tests require an appengine-testing.jar wich conflicts with the main appengine-api-xxx.jar of the poject. That way, I was able to run tests for GAE but it conflicted with a normal run/debug launch. To be able to run the app in my local machine, I had to remove the appengine-testing.jar and then, a lot of compilation errors appeared in my test/ clases.
If you want an advice, set your test clases in another project (where you can use the jars without conflict)
Otherwise, if you got make it work, please, tell me how did you do.
Thanks a lot.
把它放在最不让你痛苦的地方。
Google App Engine 上的 GWT 目前还很新。 你是
乐观地期望有一个“标准”的地方,特别是因为
您已经发现这些工具的功能不一致。
既然您已经接受了从“src/”开始的源代码,为什么不呢
将测试源放在“test/”中? 这当然是许多人的标准
上下文。
Put it where it pains you least.
GWT on Google App Engine is pretty new at this point; you are
optimistic to expect there is a "standard" place, especially since
you've already found an inconsistency in what the tools do.
Since you've already accepted the source starting at "src/", why not
put the test source in "test/"? This is certainly standard in many
contexts.