JUnit 可以用作 Spring 中浏览器测试的替代方案吗?
我正在构建一个 Spring Web 应用程序,到目前为止我的所有测试都是使用浏览器。
这包括启动服务器、打开浏览器窗口并检查访问任何页面是否会导致错误。
这开始变得重复,并且似乎不是最有效的方法。
由于 Junit jar 文件已经在我的项目中,是否可以将其用作此浏览器测试的替代方案,如果可以,是否有关于如何开始让 JUnit 模拟打开浏览器访问 Web 应用程序的操作的任何提示?
I'm building a Spring web app and up until now all of my testing is using a browser.
This involves starting the server, opening a browser window and checking to see if accessing any of the pages causes an error.
This is starting to get repetitive and doesn't seem to be the most efficient way to do this.
Since the Junit jar file is already in my project, could it be used as an alternative to this browser testing and, if so, any tips on how to get started making JUnit simulate the act of opening a browser to access the web app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看 Selenium。它允许您使用 JUnit 或 TestNG 编写功能测试脚本,并在浏览器中自动执行它们。
Take a look at Selenium. It allows you to script functional tests using JUnit or TestNG and execute them in a browser, automatically.
您可以使用 HTMLUnit 扩展编写脚本来从 JUnit 驱动网站。
我使用了一段时间并且在我当时做的这个网站上工作得很好。
请参阅http://htmlunit.sourceforge.net/
You can use the HTMLUnit extension to script to drive the web site from JUnit.
I used a while back and worked fine for thi site I was doing then.
see http://htmlunit.sourceforge.net/
我建议您尝试机器人框架。这是由诺基亚西门子通信工程师开发的开源测试框架。
它主要基于 python 和 Selenium 测试库构建。它还支持通过 Jython 库测试 Java/J2EE 服务器端代码。我个人有时会在工作中使用它,编写测试用例就像通过使用关键字描述端到端流程一样简单(大多数必需的关键字已经内置)。如果您发现 Selenium 很难使用,您可以尝试一下。 Robot 框架提供了对原始 selenium 的相当简单的抽象,并且还具有进行 Java/J2EE 服务器端调用的功能。
问候,
纳根德拉大学
I suggest you to try the Robot Framework. This is an open source testing framework developed by engineers in Nokia Siemens Networks.
It is primarily built on python and the Selenium testing libraries. It also includes support for testing Java/J2EE server side code through Jython libraries. I personally use it in my work sometimes, and writing a test case is just as easy as describing an end-to-end flow through the use of Keywords (most of required ones are already inbuilt). You could go ahead and give this a shot if you find Selenium a li'l tough to work with. The Robot framework provides a fairly simple abstraction over raw selenium, coupled with the power to make Java/J2EE server-side calls too.
Regards,
Nagendra U M