regressy_common 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +177 -6
- data/lib/regressy_common/utils/standard_logger.rb +1 -1
- data/lib/regressy_common/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c08038e6fb8863b06fc9d27438c8f3dee51a81ed7207d14f5541d4ef772d2722
|
4
|
+
data.tar.gz: ff7a4f43f7a7df2b55852c08e1b5c73e44fc26ad3105773ffd63805edb441aae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0bbfe572699a1bfa37cd1be4028d1b14d15233786296302f12951f01456e14d417ac8049ce16e8e0e5aa60e98565f8794e01bb666a72a3dde45bc25041c7f54
|
7
|
+
data.tar.gz: 9a7017a75b8e7bd7843589c5bbb6e6275e0fdde060d570b1cd6e1c27baee7a360bfcee40ab325bcdd54d68e54af3fa56a351a2daae907c431cfcca2ea5fcf313
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# RegressyCommon
|
2
2
|
|
3
|
-
|
3
|
+
RegressyCommonは、[Regressy](https://regressy.fluxware.jp)でe2eテストを構築するためのライブラリです。
|
4
4
|
|
5
|
-
|
5
|
+
Ruby言語とtest-unitフレームワークを利用して、e2eテストを構築します。
|
6
6
|
|
7
|
-
##
|
7
|
+
## インストール
|
8
8
|
|
9
|
-
|
9
|
+
Gemfileに追加し、bundleを実行します。
|
10
10
|
|
11
11
|
```ruby
|
12
12
|
gem 'regressy_common'
|
@@ -20,9 +20,180 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install regressy_common
|
22
22
|
|
23
|
-
##
|
23
|
+
## 使い方
|
24
|
+
|
25
|
+
RegressyCommonは、ページオブジェクトモデルに基づくe2eテスト構築を支援するライブラリです。
|
26
|
+
|
27
|
+
ページオブジェクト、テストセット、テストスイートでテスト全体を構成します。
|
28
|
+
|
29
|
+
### ディレクトリ構成
|
30
|
+
|
31
|
+
ディレクトリ構成の例を以下に示します。
|
32
|
+
|
33
|
+
```
|
34
|
+
your-e2e-project
|
35
|
+
├── app
|
36
|
+
│ ├── pages # ここにページオブジェクトを格納します。
|
37
|
+
│ ├── test_sets # ここにテストセットを格納します。
|
38
|
+
│ ├── test_suites # ここにテストスイートを格納します。
|
39
|
+
│ :
|
40
|
+
└── config
|
41
|
+
```
|
42
|
+
|
43
|
+
- ページオブジェクト: テスト対象サイトのページに対応するオブジェクト。
|
44
|
+
1ページに対して1オブジェクトが対応します。
|
45
|
+
- テストセット: 関連した一連のテストの集合。
|
46
|
+
test-unit における TestCaseに相当。
|
47
|
+
ここで定義したテストからページオブジェクトを操作し、テストを実行します。
|
48
|
+
- テストスイート: 関連した一連のテストセットの集合。
|
49
|
+
ここで定義したテストスイートから、関連するテストセットを操作します。
|
50
|
+
|
51
|
+
## ページオブジェクト
|
52
|
+
|
53
|
+
- ページを司るオブジェクトです。
|
54
|
+
- テスト対象のサイトを構成する1ページに対して1オブジェクトを定義します。
|
55
|
+
- 以下にページオブジェクトの基底クラスを例示します。
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
require 'test/unit'
|
59
|
+
require 'regressy_common'
|
60
|
+
module Pages
|
61
|
+
class Base
|
62
|
+
include Test::Unit::Assertions
|
63
|
+
include RegressyCommon::Checker
|
64
|
+
include RegressyCommon::Clicker
|
65
|
+
include RegressyCommon::Sender
|
66
|
+
include RegressyCommon::Selector
|
67
|
+
|
68
|
+
def initialize(test_case)
|
69
|
+
@test_case = test_case
|
70
|
+
@driver = test_case.driver
|
71
|
+
@target_host = test_case.target_host
|
72
|
+
end
|
73
|
+
|
74
|
+
def logger
|
75
|
+
RegressyCommon::Utils::StandardLogger.instance
|
76
|
+
end
|
77
|
+
|
78
|
+
def take_snap(tag=nil)
|
79
|
+
tag ||= %(#{self.class.name}##{caller_locations(1).first.label})
|
80
|
+
RegressyCommon::SnapShot.new(@driver, tag).take_and_store
|
81
|
+
end
|
82
|
+
|
83
|
+
def set_window_size
|
84
|
+
@driver.manage.window.resize_to(1600, 1024)
|
85
|
+
end
|
86
|
+
|
87
|
+
def access_to_target_page
|
88
|
+
@driver.get(page_url)
|
89
|
+
assert_element_exists(:xpath, xpath_page_title)
|
90
|
+
end
|
91
|
+
|
92
|
+
protected
|
93
|
+
|
94
|
+
def page_url
|
95
|
+
raise "should implement this method"
|
96
|
+
end
|
97
|
+
def xpath_page_title
|
98
|
+
raise "should implement this method"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
```
|
103
|
+
|
104
|
+
- そして、基底クラスを継承するページクラス。
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
require 'pages/base'
|
108
|
+
class Pages::Index < Pages::Base
|
109
|
+
|
110
|
+
def execute_search(word)
|
111
|
+
assert_element_present(:xpath, xpath_search_input )
|
112
|
+
send_keys(:xpath, xpath_search_input, word)
|
113
|
+
retry_click(:xpath, xpath_search_submit)
|
114
|
+
assert_element_present(:xpath, xpath_search_result)
|
115
|
+
end
|
116
|
+
|
117
|
+
protected
|
118
|
+
|
119
|
+
def page_url
|
120
|
+
%(#{@test_case.target_host}/)
|
121
|
+
end
|
122
|
+
def xpath_page_title
|
123
|
+
%(//title[contains(text(), "Yahoo! JAPAN")])
|
124
|
+
end
|
125
|
+
def xpath_search_input
|
126
|
+
%(//input[@type="search"])
|
127
|
+
end
|
128
|
+
def xpath_search_submit
|
129
|
+
%(//button[@type="submit"])
|
130
|
+
end
|
131
|
+
def xpath_search_result
|
132
|
+
%(//a[contains(@href, "regressy")])
|
133
|
+
end
|
134
|
+
end
|
135
|
+
```
|
136
|
+
|
137
|
+
## テストセット
|
138
|
+
|
139
|
+
- テストの例。
|
140
|
+
```ruby
|
141
|
+
require 'regressy_common'
|
142
|
+
require 'pages/index'
|
143
|
+
class SampleTest < RegressyCommon::TestSets::Base
|
144
|
+
def setup
|
145
|
+
@target_host = 'https://yahoo.co.jp'
|
146
|
+
super
|
147
|
+
end
|
148
|
+
def test_01_search
|
149
|
+
index_page = Pages::Index.new(self)
|
150
|
+
index_page.access_to_target_page
|
151
|
+
index_page.take_snap
|
152
|
+
|
153
|
+
index_page.execute_search("regressy")
|
154
|
+
end
|
155
|
+
end
|
156
|
+
```
|
157
|
+
|
158
|
+
## テストスイート
|
159
|
+
|
160
|
+
- テストスイートの例。
|
161
|
+
```
|
162
|
+
require 'test/unit'
|
163
|
+
require 'test/unit/testsuite'
|
164
|
+
require 'test/unit/ui/console/testrunner'
|
165
|
+
require 'test_sets/sample_test'
|
166
|
+
|
167
|
+
regression_test = Test::Unit::TestSuite.new("regression test")
|
168
|
+
regression_test << SampleTest.suite # default local chrome
|
169
|
+
regression_test << SampleTest.suite_with_capability(:local_firefox)
|
170
|
+
|
171
|
+
Test::Unit::UI::Console::TestRunner.run(regression_test)
|
172
|
+
```
|
173
|
+
ここで、ブラウザの種類を指定します。
|
174
|
+
|
175
|
+
## テストの実行
|
176
|
+
|
177
|
+
```
|
178
|
+
# ruby app/test_suites/regression_test.rb
|
179
|
+
Loaded suite regression test
|
180
|
+
Started
|
181
|
+
..
|
182
|
+
Finished in 33.660497466 seconds.
|
183
|
+
-----------------------------------------------------------------------------------------------------------------------
|
184
|
+
2 tests, 8 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
|
185
|
+
100% passed
|
186
|
+
-----------------------------------------------------------------------------------------------------------------------
|
187
|
+
0.06 tests/s, 0.24 assertions/s
|
188
|
+
```
|
189
|
+
|
190
|
+
## ページオブジェクトで使用する共通機能
|
191
|
+
|
192
|
+
- checker
|
193
|
+
- clicker
|
194
|
+
- sender
|
195
|
+
- selector
|
24
196
|
|
25
|
-
TODO: Write usage instructions here
|
26
197
|
|
27
198
|
## Development
|
28
199
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regressy_common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- info@fluxware.co.jp
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|