[英]How do I make a WAR archive produced with maven-assembly-plugin available for other projects' unit tests?
My problem consists of two maven projects, a server project A and a client project B. A uses maven-assembly-plugin to produce several variants of A, where one variant is a WAR archive. 我的问题包括两个Maven项目,一个服务器项目A和一个客户端项目B。A使用maven-assembly-plugin生成A的多个变体,其中一个变体是WAR存档。 The problem I am facing relates to the test-driven development of B;
我面临的问题与B的测试驱动开发有关。 how can I make the WAR archive produced in project A accessible/addressable from unit tests in project B?
如何使项目B中的单元测试可以访问/寻址项目A中产生的WAR归档文件? My idea is to construct test cases in project B where the WAR archive is deployed in an embedded Jetty server through the WebApppContext's setWar(String path) function.
我的想法是在项目B中构造测试用例,在其中通过WebApppContext的setWar(String path)函数将WAR存档部署在嵌入式Jetty服务器中。
You can declare an artifact from the other submodule as a test dependency , eg: 您可以将其他子模块中的工件声明为测试依赖项 ,例如:
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ModuleA</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
In this way, you can surely use jars from the other module. 这样,您肯定可以使用其他模块中的jar。 I am not sure if it works for a WAR file though - but it may be worth a try.
我不确定它是否适用于WAR文件-但可能值得一试。
Note that tests run against a WAR deployed in an embedded web container would hardly count as unit tests, rather integration tests. 请注意,针对部署在嵌入式Web容器中的WAR运行的测试几乎不算作单元测试,而是集成测试。 The approach that works in out project is:
在项目中可行的方法是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.