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

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

问题描述

你怎么能依赖来自 Maven 另一个模块的测试代码?

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

例如,我有 2 个模块:

Example, I have 2 modules:

  • 基础
  • 主要

我想在 Main 中使用一个测试用例来扩展 Base 中的基础测试类.这可能吗?

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

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

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

推荐答案

我推荐使用 type 而不是分类器(另见:classifier).它更明确地告诉 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天全站免登陆