在 Java 环境中创建自动化测试的最佳方法

发布于 2024-12-06 14:10:02 字数 875 浏览 1 评论 0原文

我的任务是寻找进行集成单元测试的最佳方法。我们有一个非常大的 Java EE 5 应用程序(桌面)。现在我们使用一个名为 QF-TEST 的工具,这对于大型网站来说相当麻烦测试并且可能难以使用(容易破坏)任何代码更改。

我们现在想做一些更标准的事情,并为开发人员提供更多控制权。

我在这里阅读了一些帖子:

Java EE 环境中的单元测试

自动化测试 - 有点酷,尽管对于 .Net

自动化测试的最佳实践方法

Java 中最简单的自动化测试工具

从我读过的一般信息来看,JUnit/JUnitEE 可能是最好的(通过最好,我的意思是学得最快,可能是 JAVA 标准)。

JUnit 是大型 Java EE 应用程序的最佳选择吗?其他人认为更好的其他选择还有哪些(如果有的话)?

谢谢!

I have been tasked with finding the best way to do integrated unit testing. We have a very large Java EE 5 application (desktop). Right now we use a tool called QF-TEST which is pretty cumbersome for large tests and can be difficult to use (easy to break) with any code changes.

We now want to do something that is more standard and gives the developers more control.

I have read a few posts here:

Unit testing in Java EE environment

Automated Testing - kind of cool, although for .Net

Best practice approach for automated testing

easiest Automated testing tool in Java

From the general information I have read JUnit/JUnitEE is probably the best (by best I mean quickest to learn and possibly the JAVA standard).

Is JUnit the way to go for large Java EE applications? What are some other options that others find better (if there are any)?

Thanks!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

只为一人 2024-12-13 14:10:02

这是一个非常广泛的问题。这是许多书籍的主题。从 JUnit 开始,开始阅读有关测试驱动设计/开发 (TDD) 的内容,并从那里开始构建。当你遇到这些问题时,提出更具体的问题。您可以从“测试感染”开始,这是一篇相当古老但仍然适用的文章在 JUnit 网站上。

That's a very broad question. It's the topic of many books. Start with JUnit, start reading about test-driven design/development (TDD), and build from there. Ask more specific questions as you come across them. You could start with "Test Infected", a rather old, yet still applicable article on the JUnit site.

独夜无伴 2024-12-13 14:10:02

我认为对于java我会选择 junittestNG 框架,如果您的应用程序涉及持久性/数据库,我会添加 dbUnit混合。

如果您有诸如 mavenantgradle ,我还建议你看看Jenkins 和类似的自动化构建工具。

我建议使用 maven,因为它有 生命周期事件测试,你可以用ant添加目标,我没有使用过gradle,但如果给我选择,我会选择gradle

I think for java I would go with either with junit or testNG frameworks, If you have persistence/data base involved in the application, I would add dbUnit to the mix.

If you have build scripts like maven or ant or gradle, I would also suggest you look into Jenkins and similar tools to automate builds.

I am suggesting maven because it has life cycle events for testing, You can add targets with ant, I have not used gradle but if I was given choice, I would choose gradle

你与昨日 2024-12-13 14:10:02

JUnit 并不是大型 Java EE 应用程序的最佳选择,它只是最低限度的要求。

但是,由于您已经有了一个应用程序,因此编写 jUnit 测试对您没有帮助,因为 jUnit 不是测试工具。 jUnit 用于 TDD 和重构安全,事后编写 jUnit 测试根本行不通。

也就是说你应该尽快学习jUnit4(60秒内就能完成)
然后了解 TDD(可以在 2-3 小时内完成)
并在以后对应用程序进行的每次代码更改中使用 jUnit。

对于已有的代码,您需要的是“代码分析器”。
这意味着工具将检查源代码是否违反编码标准、代码重复、代码覆盖率、依赖性分析和复杂性监控。
(所有这些以及更多内容都作为 eclipse 插件存在)

您可能还需要一些“java gui 测试”框架(以替换 QF-TEST)
那里有很多开源替代方案,请在网上搜索。

JUnit is not the way to go for large Java EE applications, it is a bare minimum.

But since you already have an application writing jUnit tests will not help you, because jUnit is not a testing tool. jUnit is used for TDD and refactoring safety, writing jUnit tests as an afterthought simply does not work.

That said you should learn jUnit4 as soon as possible (it can be done in 60 seconds)
and than learn about TDD (it can be done in 2-3 hours)
and use jUnit for every future code change you make to your application.

As for code you already have, what you need is 'code analyzers'.
That means tools that will check your source code for violated coding standards, code duplication, do code coverage, dependency analysis and complexity monitoring.
(All of these and more exist as eclipse plugins)

You will probably also need some 'java gui testing' framework (to replace QF-TEST)
There are a lot of open source alternatives there, search the web.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文