使用Jazz Automation编写自动化测试2014-06-11 infoq/Dedrick Boyd 译:孙镜涛Jazz Automation介绍Jazz Automation是一个测试框架,构建它的目的是为所有类型的Web系统或者 静态网站自动化同时加速验收/功能测试。它还能够容易地实现自动化集成测试。 以前的时候这种类型的测试需要人工完成,劳动强度大又不准确。借助于自动化 测试,公司能够创造高质量的应用程序,创造的产品bug更少,同时又加快了投入 市场的速度。Jazz Automation支持以下Web浏览器:IE、Firefox、Safari和 Chrome。 Jazz Automation和其他的自动化测试框架不同,它允 许测试编写者使用纯英语描述软件的工作原理。大多数自动化测试框架在执行测试之前必须使用Java和Ruby这样的语言编程, 例如Selenium和Cucumber。Jazz Automation提供了一个抽象层,测试编写者和配 置人员不需要编程。编写第一个测试脚本让我们看看下面这个测试一个电子商务网站的规格。
Feature: Go to the Amazon web site, search for Harry Porter in the book section. Find Harry Potter and the Chamber of Secrets (book2) and then add it to the cart.Background: Establish the test settings for the test Given the following settings: | url | http://www.amazon.com || platform| Vista | | browser | firefox | | browser version | 23| Scenario: Verify that we have an empty cart on the amazon home page Given I am ON the "HomePage" Then I should EXPECT | cartCount | 0 | Scenario: Search for Harry Porter from the books category Given I am ON "HomePage" And I click "allButton" And I select | selectCategory| Books| And I enter | searchField | Harry Potter |And I click "go" And I wait 5 seconds Then I should be ON the "SearchResultsPage" Scenario: From the Search Results Page, verify the first result Special Edition Harry Potter Paperback Box SetGiven I am ON "SearchResultsPage" Then I should EXPECT | firstResult | Special Edition Harry Potter Paperback Box Set | | chamberOfSecretsBook2 | visible | Scenario: Click on the Chamber Of Secrets Book2 to reveal the detailsGiven I am ON "SearchResultsPage" And I CLICK "chamberOfSecretsBook2"Then I should be ON the "BookDetailPage" Scenario: Verify the detailsGiven I am ON the "BookDetailPage" Then I should EXPECT| kindlePrice| $7.99|| hardcoverPrice | $13.94 || paperbackPrice | $8.56|Scenario: Add the book to my cartGiven I am ON the "BookDetailPage"And I click "hardcover"And I click "addToCart"Then I should be ON the "PreCheckoutPage" Scenario: On the pre-checkout page, verify the detailsGiven I am ON the "PreCheckoutPage"Then I should EXPECT| orderSubtotal| 13.94 || cartCount| 1 |Scenario: proceed to checkoutGiven I am ON the "PreCheckoutPage" And I click "proceedToCheckout" Then I should be ON the "SignInPage"The test script should be extremely easy to read and understand, right?