简体   繁体   English

JUnit可以用作Spring中浏览器测试的替代方案吗?

[英]Can JUnit be used as an alternative to browser testing in Spring?

I'm building a Spring web app and up until now all of my testing is using a browser. 我正在构建一个Spring Web应用程序,直到现在我的所有测试都在使用浏览器。

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? 由于Junit jar文件已经在我的项目中,它是否可以用作此浏览器测试的替代方案,如果是这样,有关如何开始制作JUnit的任何提示模拟打开浏览器访问Web应用程序的行为?

Take a look at Selenium . 看看Selenium It allows you to script functional tests using JUnit or TestNG and execute them in a browser, automatically. 它允许您使用JUnit或TestNG编写功能测试脚本,并自动在浏览器中执行它们。

You can use the HTMLUnit extension to script to drive the web site from JUnit. 您可以使用HTMLUnit扩展脚本来从JUnit驱动网站。

I used a while back and worked fine for thi site I was doing then. 我曾经使用了一段时间,并为我当时所做的网站工作得很好。

see http://htmlunit.sourceforge.net/ http://htmlunit.sourceforge.net/

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. 它主要基于python和Selenium测试库。 It also includes support for testing Java/J2EE server side code through Jython libraries. 它还包括通过Jython库测试Java / J2EE服务器端代码的支持。 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. 如果你发现Selenium很难与之合作,你可以继续这样做。 The Robot framework provides a fairly simple abstraction over raw selenium, coupled with the power to make Java/J2EE server-side calls too. Robot框架提供了对原始selenium的相当简单的抽象,并且还具有进行Java / J2EE服务器端调用的能力。

Regards, 问候,
Nagendra UM Nagendra UM

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM