bucky-core 0.9.0
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 +7 -0
- data/.circleci/config.yml +66 -0
- data/.codeclimate.yml +48 -0
- data/.dockerignore +11 -0
- data/.gitignore +40 -0
- data/.rspec +3 -0
- data/.rubocop.yml +76 -0
- data/.rubocop_todo.yml +51 -0
- data/Dockerfile +38 -0
- data/Dockerfile.system-test +44 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +115 -0
- data/LICENSE +201 -0
- data/README.md +246 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/bucky-core.gemspec +47 -0
- data/docker-compose.dev-with-bm.yml +28 -0
- data/docker-compose.dev.yml +18 -0
- data/docker-compose.system-test.yml +21 -0
- data/docker/nginx/Dockerfile +7 -0
- data/docker/nginx/nginx.conf +22 -0
- data/docker/nginx/public/index.html +19 -0
- data/docker/nginx/public/test_page.html +12 -0
- data/exe/bucky +214 -0
- data/lib/bucky.rb +3 -0
- data/lib/bucky/core/database/db_connector.rb +29 -0
- data/lib/bucky/core/database/test_data_operator.rb +195 -0
- data/lib/bucky/core/exception/bucky_exception.rb +39 -0
- data/lib/bucky/core/report/screen_shot_generator.rb +24 -0
- data/lib/bucky/core/test_core/test_case_loader.rb +162 -0
- data/lib/bucky/core/test_core/test_class_generator.rb +129 -0
- data/lib/bucky/core/test_core/test_manager.rb +70 -0
- data/lib/bucky/core/test_core/test_result.rb +92 -0
- data/lib/bucky/test_equipment/evidence/evidence_generator.rb +36 -0
- data/lib/bucky/test_equipment/pageobject/base_pageobject.rb +55 -0
- data/lib/bucky/test_equipment/pageobject/pages.rb +61 -0
- data/lib/bucky/test_equipment/selenium_handler/webdriver_handler.rb +66 -0
- data/lib/bucky/test_equipment/test_case/abst_test_case.rb +49 -0
- data/lib/bucky/test_equipment/test_case/e2e_test_case.rb +70 -0
- data/lib/bucky/test_equipment/test_case/linkstatus_test_case.rb +28 -0
- data/lib/bucky/test_equipment/user_operation/user_operation_helper.rb +97 -0
- data/lib/bucky/test_equipment/user_operation/user_operation_logger.rb +15 -0
- data/lib/bucky/test_equipment/user_operation/user_operator.rb +61 -0
- data/lib/bucky/test_equipment/verifications/abst_verification.rb +13 -0
- data/lib/bucky/test_equipment/verifications/e2e_verification.rb +106 -0
- data/lib/bucky/test_equipment/verifications/js_error_checker.rb +23 -0
- data/lib/bucky/test_equipment/verifications/service_verifications.rb +62 -0
- data/lib/bucky/test_equipment/verifications/status_checker.rb +180 -0
- data/lib/bucky/tools/lint.rb +69 -0
- data/lib/bucky/utils/bucky_logger.rb +25 -0
- data/lib/bucky/utils/bucky_output.rb +23 -0
- data/lib/bucky/utils/config.rb +55 -0
- data/lib/bucky/utils/requests.rb +33 -0
- data/lib/bucky/utils/yaml_load.rb +24 -0
- data/lib/bucky/version.rb +7 -0
- data/system_testing/test_bucky_project/.bucky_home +2 -0
- data/system_testing/test_bucky_project/config/bucky_config.yml +6 -0
- data/system_testing/test_bucky_project/config/e2e_config.yml +15 -0
- data/system_testing/test_bucky_project/config/linkstatus_config.yml +3 -0
- data/system_testing/test_bucky_project/config/test_db_config.yml +8 -0
- data/system_testing/test_bucky_project/services/README.md +1 -0
- data/system_testing/test_bucky_project/services/service_a/pc/pageobject/index.rb +13 -0
- data/system_testing/test_bucky_project/services/service_a/pc/parts/index.yml +6 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/pc_e2e.yml +68 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/setup_each_pc_e2e.yml +20 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/setup_teardown_each_pc_e2e.yml +35 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/teardown_each_pc_e2e.yml +20 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/linkstatus/pc_link.yml +10 -0
- data/system_testing/test_bucky_project/services/service_a/sp/pageobject/index.rb +14 -0
- data/system_testing/test_bucky_project/services/service_a/sp/parts/index.yml +6 -0
- data/system_testing/test_bucky_project/services/service_a/sp/scenarios/e2e/sp_e2e_test.yml +26 -0
- data/system_testing/test_bucky_project/services/service_a/sp/scenarios/linkstatus/sp_link.yml +10 -0
- data/system_testing/test_bucky_project/services/service_a/tablet/pageobject/index.rb +14 -0
- data/system_testing/test_bucky_project/services/service_a/tablet/parts/index.yml +6 -0
- data/system_testing/test_bucky_project/services/service_a/tablet/scenarios/e2e/tablet_e2e_test.yml +26 -0
- data/system_testing/test_bucky_project/system/evidences/README.md +1 -0
- data/system_testing/test_bucky_project/system/evidences/screen_shots/README.md +1 -0
- data/system_testing/test_bucky_project/system/logs/README.md +1 -0
- data/system_testing/test_specification.md +38 -0
- data/system_testing/testing_code/command.bats +42 -0
- data/system_testing/testing_code/e2e.bats +75 -0
- data/system_testing/testing_code/linkstatus.bats +24 -0
- data/template/make_page/pc/pageobject/sample_page.rb +23 -0
- data/template/make_page/pc/parts/sample_page.yml +9 -0
- data/template/make_page/sp/pageobject/sample_page.rb +24 -0
- data/template/make_page/sp/parts/sample_page.yml +9 -0
- data/template/make_page/tablet/pageobject/sample_page.rb +24 -0
- data/template/make_page/tablet/parts/sample_page.yml +9 -0
- data/template/new/.bucky_home +2 -0
- data/template/new/config/bucky_config.yml +6 -0
- data/template/new/config/e2e_config.yml +15 -0
- data/template/new/config/linkstatus_config.yml +3 -0
- data/template/new/config/test_db_config.yml +8 -0
- data/template/new/services/README.md +1 -0
- data/template/new/system/evidences/README.md +1 -0
- data/template/new/system/evidences/screen_shots/README.md +1 -0
- data/template/new/system/logs/README.md +1 -0
- metadata +415 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'parallel'
|
|
4
|
+
require_relative '../test_core/test_case_loader'
|
|
5
|
+
require_relative '../../utils/config'
|
|
6
|
+
require_relative './test_class_generator'
|
|
7
|
+
|
|
8
|
+
module Bucky
|
|
9
|
+
module Core
|
|
10
|
+
module TestCore
|
|
11
|
+
class TestManager
|
|
12
|
+
# Keep test conditions and round number
|
|
13
|
+
def initialize(test_cond)
|
|
14
|
+
@test_cond = test_cond
|
|
15
|
+
@re_test_count = @test_cond[:re_test_count]
|
|
16
|
+
@tdo = Bucky::Core::Database::TestDataOperator.new
|
|
17
|
+
@start_time = Time.now
|
|
18
|
+
$job_id = @tdo.save_job_record_and_get_job_id(@start_time, @test_cond[:command_and_option])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def run
|
|
22
|
+
execute_test
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Rerun by job id
|
|
26
|
+
def rerun
|
|
27
|
+
rerun_job_id = @test_cond[:job]
|
|
28
|
+
$round = @tdo.get_last_round_from_job_id(rerun_job_id)
|
|
29
|
+
@test_cond[:re_test_cond] = @tdo.get_ng_test_cases_at_last_execution(
|
|
30
|
+
is_error: 1, job_id: rerun_job_id, round: $round
|
|
31
|
+
)
|
|
32
|
+
execute_test
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
# Load test suite from test code.
|
|
38
|
+
def load_test_suites
|
|
39
|
+
test_suite_data = Bucky::Core::TestCore::TestCaseLoader.load_testcode(@test_cond)
|
|
40
|
+
raise StandardError, "\nThere is no test case!\nPlease check test condition." if test_suite_data.empty?
|
|
41
|
+
|
|
42
|
+
@tdo.update_test_suites_data(test_suite_data)
|
|
43
|
+
@tdo.add_suite_id_to_loaded_suite_data(test_suite_data)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Generate and execute test
|
|
47
|
+
def do_test_suites(test_suite_data)
|
|
48
|
+
# For checking on linkstatus
|
|
49
|
+
link_status_url_log = {}
|
|
50
|
+
tcg = Bucky::Core::TestCore::TestClassGenerator.new(@test_cond)
|
|
51
|
+
Parallel.each(test_suite_data, in_processes: Bucky::Utils::Config.instance[:parallel_num]) do |data|
|
|
52
|
+
tcg.generate_test_class(data, link_status_url_log)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def execute_test
|
|
57
|
+
@re_test_count.times do |i|
|
|
58
|
+
$round = i + 1
|
|
59
|
+
test_suite_data = load_test_suites
|
|
60
|
+
do_test_suites(test_suite_data)
|
|
61
|
+
@test_cond[:re_test_cond] = @tdo.get_ng_test_cases_at_last_execution(
|
|
62
|
+
is_error: 1, job_id: $job_id, round: $round
|
|
63
|
+
)
|
|
64
|
+
break if @test_cond[:re_test_cond].empty?
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'singleton'
|
|
4
|
+
require 'json'
|
|
5
|
+
require 'test/unit/testresult'
|
|
6
|
+
|
|
7
|
+
require_relative '../database/test_data_operator'
|
|
8
|
+
|
|
9
|
+
module Bucky
|
|
10
|
+
module Core
|
|
11
|
+
module TestCore
|
|
12
|
+
class TestResult
|
|
13
|
+
include Singleton
|
|
14
|
+
|
|
15
|
+
attr_accessor :result
|
|
16
|
+
|
|
17
|
+
def initialize
|
|
18
|
+
@result = Test::Unit::TestResult.new
|
|
19
|
+
@tdo = Bucky::Core::Database::TestDataOperator.new
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Save test result
|
|
23
|
+
# @param [Array] added_result_info
|
|
24
|
+
def save(added_result_info)
|
|
25
|
+
# Format data before saving to database.
|
|
26
|
+
test_suite_result = format_result_summary(added_result_info)
|
|
27
|
+
@tdo.save_test_result(test_suite_result)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
# Return Bucky::Test::Unit::TestResult Object
|
|
33
|
+
# @param [Array] added_result_info
|
|
34
|
+
# @return [Array] Array data for Sequel
|
|
35
|
+
def format_result_summary(added_result_info)
|
|
36
|
+
# For sequel
|
|
37
|
+
data_set = {}
|
|
38
|
+
error_test_case_name = []
|
|
39
|
+
|
|
40
|
+
##############################################
|
|
41
|
+
# Store failed cases in data set. #
|
|
42
|
+
##############################################
|
|
43
|
+
@result.faults.each do |fault|
|
|
44
|
+
case_name = fault.method_name
|
|
45
|
+
case_id = @tdo.get_test_case_id(added_result_info[case_name.to_sym][:test_suite_id], added_result_info[case_name.to_sym][:case_name])
|
|
46
|
+
error_test_case_name.push(case_name.to_sym)
|
|
47
|
+
data_set[case_name] =
|
|
48
|
+
[
|
|
49
|
+
id = nil,
|
|
50
|
+
test_case_id = case_id,
|
|
51
|
+
error_title = fault.message,
|
|
52
|
+
error_message = fault.location.join("\n"),
|
|
53
|
+
elapsed_time = added_result_info[case_name.to_sym][:elapsed_time],
|
|
54
|
+
is_error = 1,
|
|
55
|
+
job_id = $job_id,
|
|
56
|
+
round = $round
|
|
57
|
+
]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
############################################
|
|
61
|
+
# Store passed cases in data set. #
|
|
62
|
+
############################################
|
|
63
|
+
added_result_info.delete_if { |k, _v| error_test_case_name.include?(k) }
|
|
64
|
+
added_result_info.each do |case_name, added_info|
|
|
65
|
+
case_id = @tdo.get_test_case_id(added_info[:test_suite_id], added_info[:case_name])
|
|
66
|
+
data_set[case_name] =
|
|
67
|
+
[
|
|
68
|
+
id = nil,
|
|
69
|
+
test_case_id = case_id,
|
|
70
|
+
error_title = '',
|
|
71
|
+
error_message = '',
|
|
72
|
+
elapsed_time = added_info[:elapsed_time],
|
|
73
|
+
is_error = 0,
|
|
74
|
+
job_id = $job_id,
|
|
75
|
+
round = $round
|
|
76
|
+
]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Data set for sequel
|
|
80
|
+
data_set_ary = data_set.map { |_, v| v }
|
|
81
|
+
|
|
82
|
+
# Table colomn
|
|
83
|
+
column_name_ary = %i[id test_case_id error_title error_message elapsed_time is_error job_id round]
|
|
84
|
+
{
|
|
85
|
+
column: column_name_ary,
|
|
86
|
+
data_set: data_set_ary
|
|
87
|
+
}
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../core/report/screen_shot_generator'
|
|
4
|
+
require_relative '../../utils/bucky_logger'
|
|
5
|
+
|
|
6
|
+
module Bucky
|
|
7
|
+
module TestEquipment
|
|
8
|
+
module Evidence
|
|
9
|
+
class EvidenceGenerator
|
|
10
|
+
include Bucky::Utils::BuckyLogger
|
|
11
|
+
|
|
12
|
+
# Save log
|
|
13
|
+
# @param [String] file
|
|
14
|
+
# @param [Exception Object] err
|
|
15
|
+
def report(file, err)
|
|
16
|
+
Bucky::Utils::BuckyLogger.write(file, err)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Create evidence for each test category
|
|
21
|
+
class E2eEvidence < EvidenceGenerator
|
|
22
|
+
include Bucky::Core::Report::ScreenShotGenerator
|
|
23
|
+
|
|
24
|
+
def initialize(**evid_args)
|
|
25
|
+
@driver = evid_args[:driver]
|
|
26
|
+
@tc = evid_args[:test_case]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def save_evidence(err)
|
|
30
|
+
generate_screen_shot(@driver, @tc)
|
|
31
|
+
report("#{@tc}_error", err)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../utils/yaml_load'
|
|
4
|
+
require_relative '../../core/exception/bucky_exception'
|
|
5
|
+
|
|
6
|
+
module Bucky
|
|
7
|
+
module TestEquipment
|
|
8
|
+
module PageObject
|
|
9
|
+
class BasePageObject
|
|
10
|
+
include Bucky::Utils::YamlLoad
|
|
11
|
+
def initialize(service, device, page_name, driver)
|
|
12
|
+
@driver = driver
|
|
13
|
+
generate_parts(service, device, page_name)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
# Load parts file and define parts method
|
|
19
|
+
# @param [String] service
|
|
20
|
+
# @param [String] device (pc, sp)
|
|
21
|
+
# @param [String] paga_name
|
|
22
|
+
def generate_parts(service, device, page_name)
|
|
23
|
+
Dir.glob("./services/#{service}/#{device}/parts/#{page_name}.yml").each do |file|
|
|
24
|
+
parts_data = load_yaml(file)
|
|
25
|
+
|
|
26
|
+
# Define part method e.g.) page.parts
|
|
27
|
+
parts_data.each do |part_name, value|
|
|
28
|
+
self.class.class_eval { define_method(part_name) { find_elem(value[0], value[1]) } }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @param [String] method Method name for searching WebElement
|
|
34
|
+
# http://www.rubydoc.info/gems/selenium-webdriver/0.0.28/Selenium/WebDriver/Find
|
|
35
|
+
# @param [String] Condition of search (xpath/id)
|
|
36
|
+
# @return [Selenium::WebDriver::Element]
|
|
37
|
+
def find_elem(method, value)
|
|
38
|
+
if method.end_with?('s')
|
|
39
|
+
elem = @driver.find_elements(method.sub(/s$/, '').to_sym, value)
|
|
40
|
+
raise_if_element_empty(elem, method, value)
|
|
41
|
+
return elem
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
@driver.find_element(method.to_sym, value)
|
|
45
|
+
rescue StandardError => e
|
|
46
|
+
Bucky::Core::Exception::WebdriverException.handle(e)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def raise_if_element_empty(elem, method, value)
|
|
50
|
+
raise Selenium::WebDriver::Error::NoSuchElementError, "#{method} #{value}" if elem.empty?
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bucky
|
|
4
|
+
module TestEquipment
|
|
5
|
+
module PageObject
|
|
6
|
+
class Pages
|
|
7
|
+
def initialize(service, device, driver)
|
|
8
|
+
collect_pageobjects(service, device, driver)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Load page class and define page method
|
|
12
|
+
# @param [String] service
|
|
13
|
+
# @param [String] device (pc, sp)
|
|
14
|
+
# @param [Object] driver Webdriver object
|
|
15
|
+
def collect_pageobjects(service, device, driver)
|
|
16
|
+
# Create module name
|
|
17
|
+
module_service_name = service.split('_').map(&:capitalize).join
|
|
18
|
+
Dir.glob("#{$bucky_home_dir}/services/#{service}/#{device}/pageobject/*.rb").each do |file|
|
|
19
|
+
require file
|
|
20
|
+
|
|
21
|
+
page_name = file.split('/')[-1].sub('.rb', '')
|
|
22
|
+
page_class_name = page_name.split('_').map(&:capitalize).join
|
|
23
|
+
|
|
24
|
+
# Get instance of page class
|
|
25
|
+
page_class = eval(format('Services::%<module_service_name>s::%<device>s::PageObject::%<page_class_name>s', module_service_name: module_service_name, device: device.capitalize, page_class_name: page_class_name))
|
|
26
|
+
page_instance = page_class.new(service, device, page_name, driver)
|
|
27
|
+
|
|
28
|
+
# Define method by page name
|
|
29
|
+
self.class.class_eval do
|
|
30
|
+
define_method(page_name) { page_instance }
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Get Web element by page, part, num
|
|
36
|
+
# @param [Hash] args
|
|
37
|
+
def get_part(args)
|
|
38
|
+
return send(args[:page]).send(args[:part][:locate])[args[:part][:num]] if part_plural?(args)
|
|
39
|
+
|
|
40
|
+
send(args[:page]).send(args[:part])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @param [Hash] args
|
|
44
|
+
# @return [Boolean]
|
|
45
|
+
def part_plural?(args)
|
|
46
|
+
# If the part is hash and has 'num' key, it has plural elements.
|
|
47
|
+
args[:part].class == Hash && args[:part].key?(:num)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @param [Hash] args
|
|
51
|
+
# @return [Bool]
|
|
52
|
+
def part_exist?(args)
|
|
53
|
+
get_part(args)
|
|
54
|
+
true
|
|
55
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
|
56
|
+
false
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'selenium-webdriver'
|
|
4
|
+
require_relative '../../core/exception/bucky_exception'
|
|
5
|
+
require_relative '../../utils/config'
|
|
6
|
+
|
|
7
|
+
module Bucky
|
|
8
|
+
module TestEquipment
|
|
9
|
+
module SeleniumHandler
|
|
10
|
+
module WebdriverHandler
|
|
11
|
+
# Create and return webdriver object
|
|
12
|
+
# @param [String] device_type e.g.) sp, pc, tablet
|
|
13
|
+
# @return [Selenium::WebDriver]
|
|
14
|
+
def create_webdriver(device_type)
|
|
15
|
+
@@config = Bucky::Utils::Config.instance
|
|
16
|
+
driver_args = create_driver_args(device_type)
|
|
17
|
+
driver = Selenium::WebDriver.for(:remote, **driver_args)
|
|
18
|
+
driver.manage.window.resize_to(1280, 1000)
|
|
19
|
+
driver.manage.timeouts.implicit_wait = @@config[:find_element_timeout]
|
|
20
|
+
driver
|
|
21
|
+
rescue StandardError => e
|
|
22
|
+
Bucky::Core::Exception::BuckyException.handle(e)
|
|
23
|
+
end
|
|
24
|
+
module_function :create_webdriver
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
# @param [String] device_type e.g.) sp, pc, tablet
|
|
29
|
+
# @return [Hash] driver_args
|
|
30
|
+
def create_driver_args(device_type)
|
|
31
|
+
driver_args = { url: format('http://%<ip>s:%<port>s/wd/hub', ip: @@config[:selenium_ip], port: @@config[:selenium_port]) }
|
|
32
|
+
driver_args[:desired_capabilities] = generate_desire_caps(device_type)
|
|
33
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
|
34
|
+
client.open_timeout = @@config[:driver_open_timeout]
|
|
35
|
+
client.read_timeout = @@config[:driver_read_timeout]
|
|
36
|
+
driver_args[:http_client] = client
|
|
37
|
+
driver_args
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @param [String] device_type e.g.) sp, pc, tablet
|
|
41
|
+
# @return [Hash] desire_capabilities
|
|
42
|
+
def generate_desire_caps(device_type)
|
|
43
|
+
case @@config[:browser]
|
|
44
|
+
when :chrome then
|
|
45
|
+
set_chrome_option(device_type)
|
|
46
|
+
else
|
|
47
|
+
raise 'Currently only supports chrome. Sorry.'
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def set_chrome_option(device_type)
|
|
52
|
+
chrome_options = { 'goog:chromeOptions' => {} }
|
|
53
|
+
unless device_type == 'pc'
|
|
54
|
+
device_type = "#{device_type}_device_name".to_sym
|
|
55
|
+
mobile_emulation = { 'deviceName' => @@config[:device_name_on_chrome][@@config[device_type]] }
|
|
56
|
+
chrome_options['goog:chromeOptions']['mobileEmulation'] = mobile_emulation
|
|
57
|
+
end
|
|
58
|
+
chrome_options['goog:chromeOptions'][:args] = ["--load-extension=#{@@config[:js_error_collector_path]}"] if @@config[:js_error_check]
|
|
59
|
+
chrome_options['goog:chromeOptions'][:args] = ["--user-agent=#{@@config[:user_agent]}"] if @@config[:user_agent]
|
|
60
|
+
|
|
61
|
+
Selenium::WebDriver::Remote::Capabilities.chrome(chrome_options)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'test/unit'
|
|
4
|
+
require_relative '../../core/test_core/test_result'
|
|
5
|
+
|
|
6
|
+
module Bucky
|
|
7
|
+
module TestEquipment
|
|
8
|
+
module TestCase
|
|
9
|
+
class AbstTestCase < Test::Unit::TestCase
|
|
10
|
+
class << self
|
|
11
|
+
def startup
|
|
12
|
+
return if $debug
|
|
13
|
+
|
|
14
|
+
@@this_result = Bucky::Core::TestCore::TestResult.instance
|
|
15
|
+
@@added_result_info = {}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def shutdown
|
|
19
|
+
@@this_result.save(@@added_result_info) unless $debug
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Override Test::Unit::TestCase#run
|
|
24
|
+
# Save test result to own test result object.
|
|
25
|
+
def run(result)
|
|
26
|
+
super
|
|
27
|
+
@@this_result.result = result unless $debug
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def setup
|
|
31
|
+
# To make it easy to read
|
|
32
|
+
puts "\n"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def teardown
|
|
36
|
+
return if $debug
|
|
37
|
+
|
|
38
|
+
@@added_result_info[method_name.to_sym] = {
|
|
39
|
+
test_suite_id: suite_id,
|
|
40
|
+
elapsed_time: Time.now - start_time,
|
|
41
|
+
case_name: description
|
|
42
|
+
}
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def cleanup; end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'selenium-webdriver'
|
|
4
|
+
require_relative './abst_test_case'
|
|
5
|
+
require_relative '../user_operation/user_operator'
|
|
6
|
+
require_relative '../pageobject/pages'
|
|
7
|
+
require_relative '../selenium_handler/webdriver_handler'
|
|
8
|
+
require_relative '../verifications/js_error_checker'
|
|
9
|
+
require_relative '../verifications/service_verifications'
|
|
10
|
+
|
|
11
|
+
module Bucky
|
|
12
|
+
module TestEquipment
|
|
13
|
+
module TestCase
|
|
14
|
+
class E2eTestCase < Bucky::TestEquipment::TestCase::AbstTestCase
|
|
15
|
+
include Bucky::TestEquipment::SeleniumHandler::WebdriverHandler
|
|
16
|
+
include Bucky::TestEquipment::Verifications::JsErrorChecker
|
|
17
|
+
|
|
18
|
+
TEST_CATEGORY = 'e2e'
|
|
19
|
+
|
|
20
|
+
class << self
|
|
21
|
+
def startup; end
|
|
22
|
+
|
|
23
|
+
def shutdown; end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Initialize the following class
|
|
27
|
+
# - webdriver
|
|
28
|
+
# - page object
|
|
29
|
+
# - user oparation
|
|
30
|
+
# - verification
|
|
31
|
+
# @param [Hash] suite
|
|
32
|
+
def t_equip_setup
|
|
33
|
+
@driver = create_webdriver(suite_data[:device])
|
|
34
|
+
@pages = Bucky::TestEquipment::PageObject::Pages.new(suite_data[:service], suite_data[:device], @driver)
|
|
35
|
+
service_verifications_args = { service: suite_data[:service], device: suite_data[:device], driver: @driver, pages: @pages, method_name: method_name }
|
|
36
|
+
@service_verifications = Bucky::TestEquipment::Verifications::ServiceVerifications.new(service_verifications_args)
|
|
37
|
+
user_operator_args = { app: suite_data[:service], device: suite_data[:device], driver: @driver, pages: @pages }
|
|
38
|
+
@user_operator = Bucky::TestEquipment::UserOperation::UserOperator.new(user_operator_args)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Call mothod of verification
|
|
42
|
+
# @param [Hash] verify_args e.g.) {verify: "assert_title", expect: "page title"}
|
|
43
|
+
def verify(**verify_args)
|
|
44
|
+
@service_verifications.send(verify_args[:verify], verify_args)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Call method of user operation
|
|
48
|
+
# @param [Hash] op_args e.g.){page: 'top', part: 'rosen_tokyo', operation: 'click'}
|
|
49
|
+
def operate(**op_args)
|
|
50
|
+
@user_operator.send(op_args[:operate], method_name, op_args)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Check javascript error
|
|
54
|
+
def check_js_error
|
|
55
|
+
assert_no_js_error(@driver) if @@config[:js_error_check]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def setup
|
|
59
|
+
super
|
|
60
|
+
t_equip_setup
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def teardown
|
|
64
|
+
@driver.quit
|
|
65
|
+
super
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|