如何在测试执行过程中更改依赖关系的版本以测试与Maven的二进制兼容性?

发布于 2025-01-25 10:28:57 字数 951 浏览 2 评论 0原文

我目前正在研究DBunit扩展库。因此,该库取决于dbunit。

我将版本提取为Maven属性。

<properties>
    <dbunit.version>2.4.8</dbunit.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <version>${dbunit.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

这使我可以使用另一个dbunit版本运行maven构建

mvn test -Ddbunit.version=2.7.3

,但它也更改了编译器使用的dbunit版本。因此,我测试源代码兼容性与另一个dbunit版本。

我想通过Maven构建回答的问题是:

如果我使用与DBUNIT 2.4.8一起使用DBUNIT 2.7.3在运行时使用的库,我的库工作正常吗?

我想介绍版本范围,以便库的客户端可以选择他们要使用的版本,但是为此,我想测试哪些版本可行。

maven-surefire-plugin允许我添加其他类路径。但是,只有我知道自由的道路。我想使用GAV(组伪像版)格式。

我该如何解决?您知道另一个可以处理此类情况的插件吗?

I'm currently working on a dbunit extension library. Thus this library depends on dbunit.

I extracted the version as a maven property.

<properties>
    <dbunit.version>2.4.8</dbunit.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <version>${dbunit.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

This allows me to run the maven build with another dbunit version

mvn test -Ddbunit.version=2.7.3

But it also change the dbunit version that the compiler uses. Thus I test source code compatibility to another dbunit version.

The question I want to answer with my maven build is:

Does my library work normal, as specified by the tests, if I use the library that was build against dbunit 2.4.8 with dbunit 2.7.3 at runtime?

I would like to introduce version ranges so that clients of the library can choose which version they want to use, but to do that I want to test which versions work.

The maven-surefire-plugin allows me to add additional classpath entries. But only if I know the path of a lib. I would like to use the GAV (group artifact version) format.

How can I solve this? Do you know another plugin that can handle such cases.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文