在 Java 环境中创建自动化测试的最佳方法
我的任务是寻找进行集成单元测试的最佳方法。我们有一个非常大的 Java EE 5 应用程序(桌面)。现在我们使用一个名为 QF-TEST 的工具,这对于大型网站来说相当麻烦测试并且可能难以使用(容易破坏)任何代码更改。
我们现在想做一些更标准的事情,并为开发人员提供更多控制权。
我在这里阅读了一些帖子:
自动化测试 - 有点酷,尽管对于 .Net
从我读过的一般信息来看,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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个非常广泛的问题。这是许多书籍的主题。从 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.
我认为对于java我会选择 junit 或 testNG 框架,如果您的应用程序涉及持久性/数据库,我会添加 dbUnit混合。
如果您有诸如 maven 或 ant 或 gradle ,我还建议你看看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
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.