集成测试整个*现有*应用程序(自动执行测试套件)
我刚刚加入了一个开发现有 Java Web 应用程序的团队。我的任务是创建一个自动化集成测试套件,当开发人员提交到我们的持续集成服务器 (TeamCity) 时,该套件应该运行,该服务器会自动部署到我们的临时服务器 - 因此实际上测试将针对我们的临时 Web 应用程序服务器运行。
我读过很多关于使用 Watir、Selenium 和 RWebSpec 等框架进行自动化集成测试的文章。我已经在所有这些方面创建了测试,虽然我更喜欢 Watir,但我对任何事情都持开放态度。
我还不清楚的是如何为应用程序创建整个测试套件,以及如何在执行某些脚本时使该套件完整执行。我可以愉快地创建不同复杂度的单独测试,但在如何将所有内容结合在一起形成有用的东西方面,我的知识存在差距。
有人对如何创建完整的测试套件并使其自动执行有任何建议吗?
谢谢!
I have just joined a team working on an existing Java web app. I have been tasked with creating an automated integration test suite that should run when developers commit to our continuous integration server (TeamCity), which automatically deploys to our staging server - so really the tests will be run against our staging web app server.
I have read a lot of stuff about automated integration testing with frameworks like Watir, Selenium and RWebSpec. I have created tests in all of these and while I prefer Watir, I am open to anything.
The thing that hasn't become clear to me is how to create an entire test suite for an application, and how to have that suite execute in it's entirety upon execution of some script. I can happily create individual tests of varying complexity, but there is a gap in my knowledge about how to tie everything together into something useful.
Does anyone have any advice on how to create a full test suite and have it execute automatically?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通常,您将使用 Rake 来自动执行测试。假设您使用 Test::Unit 进行测试,您将使用以下内容设置 Rakefile:
默认情况下,这会配置项目“test”文件夹下的所有测试套件文件。然后,您可以使用以下命令运行它们:
然后它将执行整个项目的所有测试套件。您可以使用以下语法告诉它运行特定测试:
由于您使用的是 TeamCity,因此您可以创建一个构建并使用 Rake 运行程序来执行您的测试套件。 TeamCity 会将所有测试信息(输出、堆栈跟踪等)提取到 UI 中,就像使用 JUnit 一样。这是一个非常好的整合。
作为参考,您的测试套件将如下所示:
这样您就可以根据需要对每个测试套件中的测试用例进行排序。
Typically you are going to use Rake to automate the test execution. Assuming you are using Test::Unit for your testing you would setup your Rakefile With the following contents:
This configures all test suite files under your project "test" folder by default. You can then run them with the command below:
and it will then execute all your test suites for your entire project. You can tell it to run a specific test by using the following syntax:
Since you are using TeamCity you can then create a build and use the Rake runner to execute your test suites. TeamCity will pull all of the test information (output, stack traces, etc.) into the UI just like it does with JUnit. It is a very good integration.
For reference, your test suites would look something like this:
This way you can sequence your test cases within each test suite as desired.
我最终使用 Rspec 编写测试来对 Watir(准确地说是 Celerity)对象进行断言。这使我能够使用 Rake 自动运行测试。有一些关于一起使用 Rspec 和 Rake 的好文章。我们的构建服务器 (teamcity) 有 Rake 任务的钩子,所以效果很好。我花了一段时间才将所有内容拼凑在一起,所以我想我会在这里发布最终的解决方案。
I ended up writing the tests using Rspec to make assertions against Watir (Celerity, to be precise) objects. This allowed me to use Rake to automate the running of the tests. There is a few good articles out there about using Rspec and Rake together. Our build server (teamcity) has hooks for Rake tasks so this works well. It took me a while to piece everything together in my mind so I thought I would post the eventual solution here.
要运行文件中的 Watir 测试,只需运行该文件:
要在多个文件中执行测试,请运行所有文件。您可以创建一个将运行它们的文件(例如 all_tests.rb):
然后运行该文件:
$ ruby all_tests.rb
我对 TeamCity 不熟悉,但您应该能够从中运行 all_tests.rb 。
To run a Watir test that is in a file, just run the file:
To execute tests in several files run all files. You can create a file that will run them all (for example all_tests.rb):
and then just run the file:
$ ruby all_tests.rb
I am not familiar with TeamCity, but you should be able to just run all_tests.rb from it.