简体   繁体   English

如何在junit java项目上导入Web应用程序

[英]how to import a web application on a junit java project

i wrote few test cases using junit and mockito for a web application, while writing test cases , i gave dependency on build path as one other project which is a dynamic web application. 我为Web应用程序使用junit和mockito编写了一些测试用例,在编写测试用例时,我像其他一个动态Web应用程序项目一样依赖于构建路径。 now i have written all test cases using mocking and junit , but don't know how to give that web application as dependency to my junit project now when i have to deploy it , eclipse can have dependent project on build path it worked like that but how can we do that outside of any IDE , specially web application. 现在我已经使用嘲笑和junit编写了所有测试用例,但是现在当我不得不部署它时,我不知道如何将该Web应用程序作为对我的junit项目的依赖,eclipse可以在其工作路径上使依赖项目像这样工作,但是我们如何在任何IDE(特别是Web应用程序)之外执行此操作。

Thanks. 谢谢。

Run your tests inside your web project. 在Web项目中运行测试。 Define another source package like '/src/test/' and put them there. 定义另一个源程序包,例如“ / src / test /”,并将其放在此处。 Then modify your ant script: 然后修改您的ant脚本:

  • run these tests on build or test 在构建或测试中运行这些测试
  • exclude this source package on war. 在战争中排除此源码包。

Alternative extract common classes, which both projects are using, and create a new project jar. 另一种方法是提取两个项目都在使用的通用类,然后创建一个新的项目jar。 Then import this new jar on both projects as dependency. 然后在两个项目上将此新jar导入为依赖项。

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

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