升级到JUnit4并通过一起运行它们来保留传统的JUnit 3测试和测试套件 [英] Upgrading to JUnit4 and keeping legacy JUnit 3 tests and test suites by running them together

查看:160
本文介绍了升级到JUnit4并通过一起运行它们来保留传统的JUnit 3测试和测试套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我很惊讶没找到答案。如果我遗漏了一些基本内容,我将非常乐意知道这一点。



有一个大型遗留代码库升级到Java 6(从1.4开始)。代码中存在大量JUnit 3测试,并将其组织到测试套件中,该套件在Eclipse中与JUnit 4默认运行程序成功运行。



现在,我正在添加纯JUnit 4测试的新测试(注释,没有TestCase等)。什么是一起运行旧的JUnit 3测试套件和新的JUnit 4测试?

解决方案

只需使用'JUnit4'运行配置中的测试运行器。



JUnit4二进制文件具有向后兼容层,允许它在同一测试套件中同时具有JUnit3和JUnit4样式类。



对于命令行构建,只需使用JUnit4 jar而不是JUnit3。



这是为了简化您现在正在进行的迁移而完成的。



此外,它在我的项目中也能正常工作。


I was surprised not to find the answer so far. If I am missing something basic I will be more than happy to know that.

There is a large legacy code base that was upgraded to Java 6 (from 1.4). Large number of JUnit 3 tests are present in the code and are organized into test suite that runs successfully with JUnit 4 default runner in Eclipse.

Now, I am adding new tests that are pure JUnit 4 tests (annotations, no TestCase, etc.). What would be a way of running both old JUnit 3 test suite and new JUnit 4 tests together?

解决方案

Just use 'JUnit4' test runner in your run configuration.

JUnit4 binaries have a backward compatibility layer that allows it to have both JUnit3 and JUnit4 style classes in the same test suite.

For command line builds just use JUnit4 jars instead of JUnit3.

This was done specifically to ease migration that you are doing now.

Also, it works fine in my project.

这篇关于升级到JUnit4并通过一起运行它们来保留传统的JUnit 3测试和测试套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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