17. TAFのテストの具体例の紹介:テストケース(1)
class Something_Create_Test extends Mage_Selenium_TestCase
{
// 前提条件設定
protected function assertPreConditions()
{
$this->loginAdminUser(); // 管理者ログイン
$this->assertTrue($this->checkCurrentPage('dashboard'),
'Wrong page is opened');
// 管理メニューのmanage_storesを選択
$this->navigate(‘manage_stores’); // ①
// manage_storesが表示されていることを確認
$this->assertTrue($this->checkCurrentPage(‘manage_stores’), // ②
'Wrong page is opened');
}
Copyright (C) 2012 FLATz Inc. All rights reserved. 17
18. TAFのテストの具体例の紹介:テストケース(2)
// 管理画面ナビゲーション動作
public function test_Navigation() {
// 検証
$this->assertTrue($this->clickButton(‘create_store_view’), // ③
'There is no "Create Store View" button on the page');
$this->assertTrue($this->checkCurrentPage('new_store_view'),
'Wrong page is opened');
$this->assertTrue($this->controlIsPresent('button', 'back'),
'There is no "Back" button on the page');
$this->assertTrue($this->controlIsPresent(‘button’, ‘save_store_view’),
'There is no "Save" button on the page');
$this->assertTrue($this->controlIsPresent('button', 'reset'),
'There is no "Reset" button on the page');
}
Copyright (C) 2012 FLATz Inc. All rights reserved. 18
19. TAFのテストの具体例の紹介:テストケース(3)
// 必須フィールドのみのテスト
public function test_WithRequiredFieldsOnly()
{
// フォームにセットするデータ読み込み
$storeData = $this->loadData(‘generic_store’, Null, ‘store_name’); // A
// 操作
$this->clickButton(‘create_store’);
$this->fillForm($storeData);
$this->saveForm(‘save_store’);
// 検証
$this->assertTrue($this->successMessage(‘success_saved_store’) // ④
, $this->messages);
$this->assertTrue($this->checkCurrentPage(‘manage_stores’), // ①
'After successful creation store should be redirected to Manage Stores page');
}
}
Copyright (C) 2012 FLATz Inc. All rights reserved. 19
20. TAFのテストの具体例の紹介:UIMap
manage_stores:
mca: system_store/ // ②
click_xpath: //ul[@id=‘nav’]//a[contains(@href, ‘system_store’)] // ①
title: Stores / System / Magento Admin
uimap:
buttons:
create_store_view: button[span=‘Create Store View’] // ③
messages:
success_saved_store: li[normalize-space(@class)=‘success-msg’]// ④
Copyright (C) 2012 FLATz Inc. All rights reserved. 20
21. TAFのテストの具体例の紹介:DataSet
generic_store: // A
website: Main Website
store_name: Generic Store(%randomize%)
root_category: Default Category
edit_store:
store_name: Main Website Store
root_category: Default Category
default_store_view: Default Store View
Copyright (C) 2012 FLATz Inc. All rights reserved. 21
22. 実際のソースコードめぐり
Copyright (C) 2012 FLATz Inc. All rights reserved. 22