在Maven中共享测试代码 [英] Sharing Test code in Maven

查看:50
本文介绍了在Maven中共享测试代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何依赖Maven中另一个模块的测试代码?

How can you depend on test code from another module in Maven?

例如,我有2个模块:

  • 基础
  • 主要

我希望Main中的一个测试用例可以扩展Base中的一个基本测试类.这可能吗?

I would like a test case in Main to extend a base test class in Base. Is this possible?

更新:找到了一个可接受的答案,其中涉及创建一个测试罐

Update: Found an acceptable answer, which involves creating a test jar.

推荐答案

我建议使用 type而不是分类符(另请参见:分类符).它更清楚地告诉Maven您正在做什么(我发现m2eclipse和q4e都更喜欢它).

I recommend using type instead of classifier (see also: classifier). It tells Maven a bit more explicitly what you are doing (and I've found that m2eclipse and q4e both like it better).

<dependency>
  <groupId>com.myco.app</groupId>
  <artifactId>foo</artifactId>
  <version>1.0-SNAPSHOT</version>
  <type>test-jar</type>
  <scope>test</scope>
</dependency>

这篇关于在Maven中共享测试代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆