为 JAva Web 应用程序编写自动化测试的最佳方法是什么
我发现对于 java 自动化测试来说,更好的方法是使用 Cruise Control(java)、JUNIT(java 测试框架)以及 Watij。 任何进一步的建议请。 谁已经成功集成了这些工具,以及发现了哪些限制。
问候
I have found out that for java automation testing better approach would be to use Cruise Control(java), JUNIT (java testing framework) along with Watij. Any further suggestions please. Any one who has succesfully integrated these tools and what limitations are found for this.
regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们通常尝试在 3 个级别上测试应用程序:
为了测试自动化和持续集成,我们的项目是使用 Maven 和 Hudson 构建的。
我们目前正在研究的改进之一是使用 Groovy 而不是 Java 进行测试。
我们必须解决的一些问题:在测试用例设置中创建基本数据(基于对象母体模式)、测试套件的组织(因为所有测试都可能需要大量时间来运行)、处理测试代码中的重复等等摆弄 Maven 和 Selenuim,但从长远来看绝对是值得的。
We generally try to test application on 3 levels:
For test automation and continuous integration, our projects are built with Maven and Hudson.
One of the improvements we are looking into at the moment is using Groovy instead of Java for the tests.
Some of the issues we had to resolve: creation of basic data in test case setup (based on Object Mother pattern), organization of test suits since all tests can take a lot of time to run, dealing with duplication in test code and a lot of fiddling with Maven and Selenuim, but is definitely worth it in a long run.
我的一位同事是 Watir 的忠实粉丝,我猜它与 Watij 类似。 我喜欢 Selenium,并且一直在考虑使用 碲 最近。
无论如何,将其中任何一个与 CruiseControl 或 Hudson (我最喜欢的)是处理 Web 应用程序功能测试的好方法。 JUnit 非常适合单元测试甚至集成测试。
功能性 Web 应用程序测试的限制:
虽然您可以告诉用户单击“左侧菜单中的第一项”,但告诉计算机执行相同操作并不那么容易。 Web 应用程序测试框架无法查看屏幕并轻松辨别页面上的哪些元素构成菜单。 他们需要更多关于与什么元素交互的细节,而这反过来又需要一些关于如何构建 HTML 页面的知识。 随着页面的变化,测试也会发生变化。
当页面某个部分的每一个微小变化都会破坏页面其他不相关部分的测试时,这些测试被称为“脆弱”。 确保测试更加稳定需要一些经验,就像常规单元测试一样。 例如,使用元素 ID 或名称来引用页面上的元素,而不是其完整的 XPath(可能很长且难以阅读且脆弱)或其文本内容(如果可能更改)。
One of my co-workers is a big fan of Watir which I'm guessing is similar to Watij. I like Selenium, and have been considering playing with Tellurium lately.
In any case, tying any of those together with a Continuous Integration engine like CruiseControl or Hudson (my favorite) is a great way to handle functional testing for web applications. And JUnit is great for unit tests and even integration tests.
Limitations to functional web application testing:
While you can tell a user to click on "the first item in the menu on the left-hand side", telling the computer to do the same isn't so easy. Web application testing frameworks can't look at the screen and readily discern what elements on the page constitute a menu. They need more specifics on what element to interact with, and that in turn requires some knowledge of how the HTML page is constructed. And as the page changes, so can the tests.
When every little change in one part of the page breaks the tests in other, unrelated parts of page, those tests are called "brittle". Making sure the tests are more stable takes some experience, just as it does in regular unit testing. For example, use element ID or name to refer to the elements on a page, not their full XPath (could be long and unreadable as well as brittle) or their text content (if it might change).
我们喜欢使用 WATIR 进行 Web 应用程序的功能测试。 它是 Ruby 的浏览器自动化包。 易于学习,并且在编写许多测试用例后我们没有遇到任何障碍。
We like to use WATIR for functional testing of web applications. It's a browser automation package for Ruby. Easy to learn and we haven't run into any roadblocks after writing many test cases.