SimpliTest 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -21
- data/SimpliTest.gemspec +42 -42
- data/bin/SimpliTest +22 -22
- data/lib/SimpliTest.rb +2 -2
- data/lib/SimpliTest/cli/main.rb +333 -333
- data/lib/SimpliTest/config/configuration.rb +107 -107
- data/lib/SimpliTest/config/directory_paths.rb +36 -36
- data/lib/SimpliTest/config/environment.rb +67 -67
- data/lib/SimpliTest/config/local_environment.rb +20 -20
- data/lib/SimpliTest/config/profiles/chrome.rb +18 -18
- data/lib/SimpliTest/config/profiles/firefox.rb +14 -14
- data/lib/SimpliTest/config/profiles/internet_explorer.rb +11 -11
- data/lib/SimpliTest/config/profiles/phantom.rb +9 -9
- data/lib/SimpliTest/config/profiles/phantom_debug.rb +12 -12
- data/lib/SimpliTest/config/profiles/selenium.rb +13 -13
- data/lib/SimpliTest/config/screen_size.rb +25 -25
- data/lib/SimpliTest/config/steps.rb +8 -8
- data/lib/SimpliTest/helpers/data_validation.rb +60 -60
- data/lib/SimpliTest/helpers/file.rb +38 -38
- data/lib/SimpliTest/helpers/project_setup.rb +186 -186
- data/lib/SimpliTest/helpers/step_helpers/custom_chrome_helpers.rb +14 -14
- data/lib/SimpliTest/helpers/step_helpers/custom_date_helpers.rb +64 -64
- data/lib/SimpliTest/helpers/step_helpers/custom_form_helpers.rb +66 -66
- data/lib/SimpliTest/helpers/step_helpers/custom_phantomjs_helpers.rb +49 -49
- data/lib/SimpliTest/helpers/step_helpers/custom_selenium_helpers.rb +41 -41
- data/lib/SimpliTest/helpers/step_helpers/html_selectors_helpers.rb +154 -154
- data/lib/SimpliTest/helpers/step_helpers/navigation_helpers.rb +206 -206
- data/lib/SimpliTest/helpers/step_helpers/tolerance_for_sync_issues.rb +38 -38
- data/lib/SimpliTest/helpers/step_helpers/within_helpers.rb +6 -6
- data/lib/SimpliTest/helpers/windows_ui.rb +51 -51
- data/lib/SimpliTest/steps/debugging_steps.rb +19 -19
- data/lib/SimpliTest/steps/form_steps.rb +348 -352
- data/lib/SimpliTest/steps/form_verification_steps.rb +189 -189
- data/lib/SimpliTest/steps/navigation_steps.rb +58 -47
- data/lib/SimpliTest/steps/scoper.rb +42 -42
- data/lib/SimpliTest/steps/verification_steps.rb +306 -306
- data/lib/SimpliTest/tasks/document.rb +169 -169
- data/lib/SimpliTest/tasks/examples.rb +18 -18
- data/lib/SimpliTest/tasks/testinstall.rb +5 -5
- data/lib/SimpliTest/templates/NewSimpliTestProject/Readme.txt +4 -4
- data/lib/SimpliTest/templates/NewSimpliTestProject/cucumber.yml +26 -26
- data/lib/SimpliTest/templates/NewSimpliTestProject/documentation/step_definitions.html +88 -87
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/RegressionTests/HelloWorld.feature +3 -3
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/SmokeTest/HelloWorld.feature +3 -3
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/accessibilityTests/HelloWorld.feature +3 -3
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/environments.yml +10 -10
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/pages.yml +26 -26
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/selectors.yml +44 -44
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/settings.yml +26 -26
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/env.rb +33 -33
- data/lib/SimpliTest/templates/NewSimpliTestProject/license.txt +29 -29
- data/lib/SimpliTest/templates/document/css/style.css +28 -28
- data/lib/SimpliTest/templates/document/index.html +60 -60
- data/lib/version.rb +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696b5d58df1dee13f6e9e04f908dab70f8b79d33
|
4
|
+
data.tar.gz: 4c3f5080cb8643238661323f35c557998f3b2161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcc2c422302f0d99262099f9d1a064bf782e62d5b37b70b6a14dfe0513e5bf5e5f9ba1ed36bfe4f3a3364aa7ada9870ecfa04cce7e6daf6d4263eefe50c1b40d
|
7
|
+
data.tar.gz: 55eb1f68cb7064779247043b873f78d19161a47c01581e9965cadd9320bfe1ab751b5775afa1891d2e4f347781346287b0974ac26949c2ddfcf050767ce88ea8
|
data/README.md
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
# SimpliTest
|
2
|
-
SimpliTest (formerly known as Caf�) was created by CGI Group Inc. members to accelerate the adoption of ATDD/BDD using Cucumber/Gherkin as the base framework. At it's core are many predefined step definitions backed by helper and utility methods. Mainly focused on the web interfaces using Selenium, but not restricted to only web apps, your imagination is it's limitation.
|
3
|
-
|
4
|
-
## Installation
|
5
|
-
|
6
|
-
1) Install Ruby & DevKit: https://rubyinstaller.org/downloads/
|
7
|
-
|
8
|
-
2) Download Selenium drivers and place them in Ruby bin
|
9
|
-
- http://www.seleniumhq.org/projects/webdriver/
|
10
|
-
|
11
|
-
3) Build this Ruby gem
|
12
|
-
$ gem build SimpliTest.gemspec
|
13
|
-
$ gem install SimpliTest
|
14
|
-
|
15
|
-
4) Use it
|
16
|
-
$SimpliTest new MyNewSimpliTestProject
|
17
|
-
or cd into an existing directory and run
|
18
|
-
$SimpliTest init
|
19
|
-
|
20
|
-
$SimpliTest run
|
21
|
-
$SimpliTest smoketest
|
1
|
+
# SimpliTest
|
2
|
+
SimpliTest (formerly known as Caf�) was created by CGI Group Inc. members to accelerate the adoption of ATDD/BDD using Cucumber/Gherkin as the base framework. At it's core are many predefined step definitions backed by helper and utility methods. Mainly focused on the web interfaces using Selenium, but not restricted to only web apps, your imagination is it's limitation.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
1) Install Ruby & DevKit: https://rubyinstaller.org/downloads/
|
7
|
+
|
8
|
+
2) Download Selenium drivers and place them in Ruby bin
|
9
|
+
- http://www.seleniumhq.org/projects/webdriver/
|
10
|
+
|
11
|
+
3) Build this Ruby gem
|
12
|
+
$ gem build SimpliTest.gemspec
|
13
|
+
$ gem install SimpliTest
|
14
|
+
|
15
|
+
4) Use it
|
16
|
+
$SimpliTest new MyNewSimpliTestProject
|
17
|
+
or cd into an existing directory and run
|
18
|
+
$SimpliTest init
|
19
|
+
|
20
|
+
$SimpliTest run
|
21
|
+
$SimpliTest smoketest
|
22
22
|
|
data/SimpliTest.gemspec
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "SimpliTest"
|
8
|
-
spec.version = SimpliTest::VERSION
|
9
|
-
spec.authors = ["CGI Federal"]
|
10
|
-
spec.email = ["SimpliTest@cgifederal.com"]
|
11
|
-
spec.description = %q{Cucumber Websteps, Helpers and Executable for Web Test Automation }
|
12
|
-
spec.summary = %q{This gem provides common web steps and command line executable for automated acceptance testing }
|
13
|
-
spec.homepage = "https://github.com/CGIFederalInc/SimpliTest"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = Dir['lib/**/*'] + Dir['features/**/*'] + Dir['bin/*'] + ["SimpliTest.gemspec","README.md"] + Dir['test/**/*']
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
spec.add_dependency "rubygems-update", "2.6.11"
|
21
|
-
spec.add_dependency "unf_ext", "0.0.7.2"
|
22
|
-
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
-
spec.add_development_dependency "sinatra", "~> 0"
|
25
|
-
spec.add_development_dependency "cucumber-sinatra", "~> 0"
|
26
|
-
spec.add_development_dependency "rake-notes", "~> 0"
|
27
|
-
spec.add_development_dependency "simplecov", "~> 0"
|
28
|
-
spec.add_development_dependency "aruba", "~> 0"
|
29
|
-
spec.add_development_dependency "hirb", "~> 0"
|
30
|
-
spec.add_development_dependency "geminabox", "~> 0"
|
31
|
-
|
32
|
-
spec.add_dependency "rake", "~> 10.4"
|
33
|
-
spec.add_dependency "cucumber", "2.1.0"
|
34
|
-
spec.add_dependency "poltergeist", "1.7.0"
|
35
|
-
spec.add_dependency "capybara", "
|
36
|
-
spec.add_dependency "rspec", "~> 3.7"
|
37
|
-
spec.add_dependency "selenium-webdriver", "~> 3.2"
|
38
|
-
spec.add_dependency "launchy", "~> 2.4"
|
39
|
-
spec.add_dependency 'parallel_tests', "~> 1.9"
|
40
|
-
spec.add_dependency 'tiny_tds', "~> 2.0"
|
41
|
-
spec.add_dependency 'rest-client', "~> 0"
|
42
|
-
spec.add_dependency "axe-matchers", "~> 1.3"
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "SimpliTest"
|
8
|
+
spec.version = SimpliTest::VERSION
|
9
|
+
spec.authors = ["CGI Federal"]
|
10
|
+
spec.email = ["SimpliTest@cgifederal.com"]
|
11
|
+
spec.description = %q{Cucumber Websteps, Helpers and Executable for Web Test Automation }
|
12
|
+
spec.summary = %q{This gem provides common web steps and command line executable for automated acceptance testing }
|
13
|
+
spec.homepage = "https://github.com/CGIFederalInc/SimpliTest"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = Dir['lib/**/*'] + Dir['features/**/*'] + Dir['bin/*'] + ["SimpliTest.gemspec","README.md"] + Dir['test/**/*']
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.add_dependency "rubygems-update", "2.6.11"
|
21
|
+
spec.add_dependency "unf_ext", "0.0.7.2"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
+
spec.add_development_dependency "sinatra", "~> 0"
|
25
|
+
spec.add_development_dependency "cucumber-sinatra", "~> 0"
|
26
|
+
spec.add_development_dependency "rake-notes", "~> 0"
|
27
|
+
spec.add_development_dependency "simplecov", "~> 0"
|
28
|
+
spec.add_development_dependency "aruba", "~> 0"
|
29
|
+
spec.add_development_dependency "hirb", "~> 0"
|
30
|
+
spec.add_development_dependency "geminabox", "~> 0"
|
31
|
+
|
32
|
+
spec.add_dependency "rake", "~> 10.4"
|
33
|
+
spec.add_dependency "cucumber", "2.1.0"
|
34
|
+
spec.add_dependency "poltergeist", "1.7.0"
|
35
|
+
spec.add_dependency "capybara", "2.5"
|
36
|
+
spec.add_dependency "rspec", "~> 3.7"
|
37
|
+
spec.add_dependency "selenium-webdriver", "~> 3.2"
|
38
|
+
spec.add_dependency "launchy", "~> 2.4"
|
39
|
+
spec.add_dependency 'parallel_tests', "~> 1.9"
|
40
|
+
spec.add_dependency 'tiny_tds', "~> 2.0"
|
41
|
+
spec.add_dependency 'rest-client', "~> 0"
|
42
|
+
spec.add_dependency "axe-matchers", "~> 1.3"
|
43
43
|
end
|
data/bin/SimpliTest
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
## Run rake tasks and cucumber features
|
3
|
-
## from SimpliTest once it's installed.
|
4
|
-
#
|
5
|
-
# Example:
|
6
|
-
#
|
7
|
-
# SimpliTest init
|
8
|
-
# SimpliTest new ProjectName
|
9
|
-
# SimpliTest "document[html]"
|
10
|
-
|
11
|
-
require 'SimpliTest/cli/main'
|
12
|
-
pwd = Dir.pwd
|
13
|
-
gem_dir = File.expand_path('..', File.dirname(__FILE__))
|
14
|
-
command, *arguments = ARGV.dup
|
15
|
-
$LOAD_PATH.unshift gem_dir
|
16
|
-
options = {
|
17
|
-
:pwd => pwd,
|
18
|
-
:gem_dir => gem_dir,
|
19
|
-
:command => command,
|
20
|
-
:arguments => arguments
|
21
|
-
}
|
22
|
-
SimpliTest::Cli::Main.new(options).execute!
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
## Run rake tasks and cucumber features
|
3
|
+
## from SimpliTest once it's installed.
|
4
|
+
#
|
5
|
+
# Example:
|
6
|
+
#
|
7
|
+
# SimpliTest init
|
8
|
+
# SimpliTest new ProjectName
|
9
|
+
# SimpliTest "document[html]"
|
10
|
+
|
11
|
+
require 'SimpliTest/cli/main'
|
12
|
+
pwd = Dir.pwd
|
13
|
+
gem_dir = File.expand_path('..', File.dirname(__FILE__))
|
14
|
+
command, *arguments = ARGV.dup
|
15
|
+
$LOAD_PATH.unshift gem_dir
|
16
|
+
options = {
|
17
|
+
:pwd => pwd,
|
18
|
+
:gem_dir => gem_dir,
|
19
|
+
:command => command,
|
20
|
+
:arguments => arguments
|
21
|
+
}
|
22
|
+
SimpliTest::Cli::Main.new(options).execute!
|
data/lib/SimpliTest.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require "version"
|
2
|
-
require "SimpliTest/config/configuration"
|
1
|
+
require "version"
|
2
|
+
require "SimpliTest/config/configuration"
|
data/lib/SimpliTest/cli/main.rb
CHANGED
@@ -1,333 +1,333 @@
|
|
1
|
-
require 'SimpliTest'
|
2
|
-
require 'SimpliTest/config/directory_paths'
|
3
|
-
require 'SimpliTest/helpers/project_setup'
|
4
|
-
require 'SimpliTest/helpers/data_validation'
|
5
|
-
#TODO: Clean this up with OptionsParser
|
6
|
-
module SimpliTest
|
7
|
-
module Cli
|
8
|
-
## Command Line Interface to the SimpliTest Suite
|
9
|
-
class Main
|
10
|
-
extend ProjectSetupHelpers
|
11
|
-
class << self
|
12
|
-
def execute(args)
|
13
|
-
new(args).execute!
|
14
|
-
end
|
15
|
-
|
16
|
-
def new(opts={})
|
17
|
-
initialize(opts)
|
18
|
-
end
|
19
|
-
|
20
|
-
def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel)
|
21
|
-
opts, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
|
22
|
-
@command = opts[:command].respond_to?(:downcase) ? opts[:command].downcase : opts[:command]
|
23
|
-
@arguments = opts[:arguments]
|
24
|
-
@arguments = @arguments.reject{|arg| (arg.to_s.empty? rescue true) } unless @arguments.is_a?(Array)
|
25
|
-
@pwd = opts[:pwd]
|
26
|
-
@gem_dir = opts[:gem_dir]
|
27
|
-
@environment = ENV['ENVIRONMENT']
|
28
|
-
@valid_commands = %w[create_update_task
|
29
|
-
document
|
30
|
-
document[csv]
|
31
|
-
document[html]
|
32
|
-
focustest
|
33
|
-
generate_npp_plugin
|
34
|
-
generate_registries
|
35
|
-
help
|
36
|
-
init
|
37
|
-
new
|
38
|
-
parallel
|
39
|
-
run
|
40
|
-
run_feature
|
41
|
-
sauce
|
42
|
-
setup
|
43
|
-
smoketest
|
44
|
-
testinstall
|
45
|
-
testproject
|
46
|
-
update
|
47
|
-
validate_service
|
48
|
-
-v
|
49
|
-
version
|
50
|
-
]
|
51
|
-
self
|
52
|
-
end
|
53
|
-
|
54
|
-
def execute!
|
55
|
-
case @command
|
56
|
-
when 'create_update_task'
|
57
|
-
create_update_task
|
58
|
-
when 'generate_npp_plugin'
|
59
|
-
generate_npp_plugin
|
60
|
-
when 'generate_registries'
|
61
|
-
generate_registries
|
62
|
-
when 'help'
|
63
|
-
puts help_text
|
64
|
-
when 'init'
|
65
|
-
initialize_project_in
|
66
|
-
when 'new'
|
67
|
-
create_new_project
|
68
|
-
when 'parallel'
|
69
|
-
run_in_parallel
|
70
|
-
when 'run'
|
71
|
-
run_as_cucumber
|
72
|
-
when 'run_feature'
|
73
|
-
run_feature
|
74
|
-
when 'setup'
|
75
|
-
setup_SimpliTest
|
76
|
-
when 'smoketest'
|
77
|
-
perform_smoke_test
|
78
|
-
when 'testinstall'
|
79
|
-
run_as_rake
|
80
|
-
when 'testproject'
|
81
|
-
testproject
|
82
|
-
when 'update'
|
83
|
-
`gem update SimpliTest`
|
84
|
-
when 'validate_service'
|
85
|
-
validate_service
|
86
|
-
when '-v', 'version'
|
87
|
-
puts "SimpliTest: v#{SimpliTest::VERSION}"
|
88
|
-
when '',nil
|
89
|
-
alert(framework_correctly_installed_message)
|
90
|
-
else
|
91
|
-
if @valid_commands.include?(@command)
|
92
|
-
alert "This feature has been deprecated. Please see the documentation folder in your project for help"
|
93
|
-
else
|
94
|
-
alert "You entered an invalid command"
|
95
|
-
end
|
96
|
-
@kernel.exit(0)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
=begin
|
100
|
-
*********************************************-------------------****************************************************************************
|
101
|
-
********************************************| CUCUMBER COMMANDS |***************************************************************************
|
102
|
-
*********************************************-------------------****************************************************************************
|
103
|
-
=end
|
104
|
-
|
105
|
-
|
106
|
-
def run_as_cucumber(args = @arguments.dup, verify_file_exists=false)
|
107
|
-
if verify_file_exists
|
108
|
-
unless File.exists? args.first
|
109
|
-
alert "#{args.first} File was Not Found. Could not run tests"
|
110
|
-
raise "FileNotFoundError"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
@project_path ||= project_path_for(@pwd)
|
114
|
-
runtime = prepare_runtime
|
115
|
-
run_dir = @project_path
|
116
|
-
Dir.chdir(run_dir)
|
117
|
-
Cucumber::Cli::Main.new(args).execute!(runtime)
|
118
|
-
end
|
119
|
-
|
120
|
-
def run_in_parallel
|
121
|
-
raise "Parallelization is not supported on Windows" if windows?
|
122
|
-
begin
|
123
|
-
`parallel_cucumber features`
|
124
|
-
rescue Exception => e
|
125
|
-
message = "There was a problem running tests in parallel"
|
126
|
-
alert message
|
127
|
-
puts e.message
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def prepare_runtime
|
132
|
-
require 'cucumber'
|
133
|
-
runtime = Cucumber::Runtime.new
|
134
|
-
runtime.load_programming_language('rb')
|
135
|
-
runtime
|
136
|
-
end
|
137
|
-
|
138
|
-
def perform_smoke_test
|
139
|
-
@project_path ||= project_path_for(@pwd)
|
140
|
-
smoke_test = File.join(@project_path, 'features', 'specifications', 'SmokeTest')
|
141
|
-
run_as_cucumber([smoke_test], true)
|
142
|
-
end
|
143
|
-
|
144
|
-
def perform_focus_test
|
145
|
-
focus_path = File.join(project_path_for(@pwd), 'features', 'specifications', 'Focus')
|
146
|
-
run_as_cucumber([focus_path], true)
|
147
|
-
end
|
148
|
-
|
149
|
-
def testproject
|
150
|
-
#TODO: Write a utility that verifies project configuration. See list below:
|
151
|
-
#YAML errors in config files
|
152
|
-
#Missing Files
|
153
|
-
#Access to Gem Step definitions
|
154
|
-
#Basically anything the user can break by changing something in the test project
|
155
|
-
@project_path ||= project_path_for(@pwd)
|
156
|
-
Dir.chdir @project_path
|
157
|
-
begin
|
158
|
-
`cucumber --dry-run`
|
159
|
-
alert('Finished checking the project. If you do not see any errors on the command prompt..you are good to go')
|
160
|
-
rescue Exception => e
|
161
|
-
message = "It seems that your project directory is corrupted \n It maybe possible for you to simply generate a new project and copy your test cases over. "
|
162
|
-
alert(message)
|
163
|
-
puts e.message
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
167
|
-
|
168
|
-
def run_feature
|
169
|
-
feature = @arguments.first
|
170
|
-
feature = File.exists?(feature) ? feature : File.join(project_path_for(@pwd), 'features', 'specifications', feature)
|
171
|
-
run_as_cucumber([feature], true)
|
172
|
-
end
|
173
|
-
=begin
|
174
|
-
*********************************************-------------------****************************************************************************
|
175
|
-
********************************************| CUCUMBER COMMANDS |***************************************************************************
|
176
|
-
*********************************************-------------------****************************************************************************
|
177
|
-
=end
|
178
|
-
|
179
|
-
=begin
|
180
|
-
*********************************************-------------------****************************************************************************
|
181
|
-
********************************************| PROJECT SETUP |***************************************************************************
|
182
|
-
*********************************************-------------------****************************************************************************
|
183
|
-
=end
|
184
|
-
|
185
|
-
## Invoked with SimpliTest new <project name>
|
186
|
-
## Creates a new example project with the <project name> with sample test cases and documentation
|
187
|
-
def create_new_project
|
188
|
-
if user_consents?
|
189
|
-
unless project_exists_in?(@pwd)
|
190
|
-
new_dir_name = @arguments.join(' ')
|
191
|
-
new_dir_path = (File.join(@pwd, new_dir_name))
|
192
|
-
make_directory(new_dir_path)
|
193
|
-
initialize_project_in(new_dir_path, true)
|
194
|
-
else
|
195
|
-
alert "You cant create a project inside an existing project!"
|
196
|
-
end
|
197
|
-
else
|
198
|
-
alert abort_message
|
199
|
-
end
|
200
|
-
end
|
201
|
-
## Invoked inside a directory with SimpliTest init
|
202
|
-
## Creates a new SimpliTest project within the current directory
|
203
|
-
# @param target_directory
|
204
|
-
# @param user_has_consented (true if user types or clicks yes)
|
205
|
-
def initialize_project_in(target_directory=@pwd, user_has_consented=false)
|
206
|
-
if (user_has_consented|| user_consents?)
|
207
|
-
if (project_exists_in?(target_directory))
|
208
|
-
alert directory_exists_message
|
209
|
-
else
|
210
|
-
project_template_dir = template_path_to 'NewSimpliTestProject'
|
211
|
-
FileUtils.cp_r(Dir[File.join(project_template_dir, '*')], target_directory)
|
212
|
-
alert("Successfully Initialized Project!")
|
213
|
-
end
|
214
|
-
else
|
215
|
-
alert abort_message
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
=begin
|
220
|
-
*********************************************-------------------****************************************************************************
|
221
|
-
********************************************| PROJECT SETUP |***************************************************************************
|
222
|
-
*********************************************-------------------****************************************************************************
|
223
|
-
=end
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
=begin
|
228
|
-
*********************************************-------------------****************************************************************************
|
229
|
-
********************************************| DATA VALIDATION |***************************************************************************
|
230
|
-
*********************************************-------------------****************************************************************************
|
231
|
-
=end
|
232
|
-
|
233
|
-
def validate_service
|
234
|
-
args = @arguments.dup
|
235
|
-
load_db_options
|
236
|
-
if args.empty?
|
237
|
-
validate_all_services
|
238
|
-
else
|
239
|
-
args.each do |service_name|
|
240
|
-
validate_service_by_name(service_name)
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
def load_db_options
|
246
|
-
require 'tiny_tds'
|
247
|
-
require 'csv'
|
248
|
-
extend DataValidationHelpers
|
249
|
-
@project_path ||= project_path_for(@pwd)
|
250
|
-
database_config = File.join(@project_path, 'features', 'support', 'config', 'database.yml')
|
251
|
-
options = YAML.load(File.read(database_config))
|
252
|
-
@db = TinyTds::Client.new(options)
|
253
|
-
end
|
254
|
-
|
255
|
-
def validate_all_services
|
256
|
-
services_dir_glob_pattern = File.join(@project_path, 'data', '*', File::SEPARATOR)
|
257
|
-
services = Dir.glob(services_dir_glob_pattern).collect{|k| k.split(File::SEPARATOR).last}
|
258
|
-
services.each do |service|
|
259
|
-
puts "Running Test for: #{service}"
|
260
|
-
validate_service_by_name service
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
def validate_service_by_name(name)
|
265
|
-
service_config_dir = File.join(@project_path, 'data', name)
|
266
|
-
variables_file = File.join(service_config_dir, 'variables.csv')
|
267
|
-
variables_csv = CSV.read(variables_file, :headers => true)
|
268
|
-
variables_hash = variables_csv.reject{|r| r.empty?}.map {|r| r.to_hash }
|
269
|
-
variables_hash.each do |set|
|
270
|
-
validate_service_against(@db, service_config_dir, set)
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
=begin
|
275
|
-
*********************************************-------------------****************************************************************************
|
276
|
-
********************************************| DATA VALIDATION |***************************************************************************
|
277
|
-
*********************************************-------------------****************************************************************************
|
278
|
-
=end
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
def run_as_rake(from_dir=@pwd)
|
285
|
-
require 'rake'
|
286
|
-
require 'pp'
|
287
|
-
Dir.chdir(@gem_dir) # We'll load rakefile from the gem's dir.
|
288
|
-
Rake.application.init
|
289
|
-
Rake.application.load_rakefile
|
290
|
-
Dir.chdir(from_dir)
|
291
|
-
Rake.application.invoke_task(@command)
|
292
|
-
end
|
293
|
-
|
294
|
-
def help_text
|
295
|
-
#TODO: Write a man page
|
296
|
-
%Q(Usage: SimpliTest [options]
|
297
|
-
|
298
|
-
Examples:
|
299
|
-
SimpliTest run features/specifications/test.feature 'run just the give one
|
300
|
-
SimpliTest run --tags @tests 'runs all with the @tests tag
|
301
|
-
SimpliTest run ' runs all of them
|
302
|
-
|
303
|
-
Options:
|
304
|
-
help - This screen
|
305
|
-
version - Version
|
306
|
-
init - Initialize this directory as a project workspace for SimpliTest
|
307
|
-
new <directory name> - Create a new SimpliTest project within directory provided
|
308
|
-
run <file path> <cucumber flags> - Run a feature also pass any cucumber flags, see cucumber --help
|
309
|
-
)
|
310
|
-
# create_update_task
|
311
|
-
# document
|
312
|
-
# document[csv]
|
313
|
-
# document[html]
|
314
|
-
# focustest
|
315
|
-
# generate_npp_plugin
|
316
|
-
# generate_registries
|
317
|
-
# parallel
|
318
|
-
# run_feature
|
319
|
-
# sauce
|
320
|
-
# setup
|
321
|
-
# smoketest
|
322
|
-
# testinstall
|
323
|
-
# testproject
|
324
|
-
# update
|
325
|
-
# validate_service
|
326
|
-
end
|
327
|
-
|
328
|
-
end #end self << class. Any methods below this are instance methods
|
329
|
-
end#end Main
|
330
|
-
end#end Cli
|
331
|
-
end#end SimpliTest
|
332
|
-
|
333
|
-
|
1
|
+
require 'SimpliTest'
|
2
|
+
require 'SimpliTest/config/directory_paths'
|
3
|
+
require 'SimpliTest/helpers/project_setup'
|
4
|
+
require 'SimpliTest/helpers/data_validation'
|
5
|
+
#TODO: Clean this up with OptionsParser
|
6
|
+
module SimpliTest
|
7
|
+
module Cli
|
8
|
+
## Command Line Interface to the SimpliTest Suite
|
9
|
+
class Main
|
10
|
+
extend ProjectSetupHelpers
|
11
|
+
class << self
|
12
|
+
def execute(args)
|
13
|
+
new(args).execute!
|
14
|
+
end
|
15
|
+
|
16
|
+
def new(opts={})
|
17
|
+
initialize(opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel)
|
21
|
+
opts, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
|
22
|
+
@command = opts[:command].respond_to?(:downcase) ? opts[:command].downcase : opts[:command]
|
23
|
+
@arguments = opts[:arguments]
|
24
|
+
@arguments = @arguments.reject{|arg| (arg.to_s.empty? rescue true) } unless @arguments.is_a?(Array)
|
25
|
+
@pwd = opts[:pwd]
|
26
|
+
@gem_dir = opts[:gem_dir]
|
27
|
+
@environment = ENV['ENVIRONMENT']
|
28
|
+
@valid_commands = %w[create_update_task
|
29
|
+
document
|
30
|
+
document[csv]
|
31
|
+
document[html]
|
32
|
+
focustest
|
33
|
+
generate_npp_plugin
|
34
|
+
generate_registries
|
35
|
+
help
|
36
|
+
init
|
37
|
+
new
|
38
|
+
parallel
|
39
|
+
run
|
40
|
+
run_feature
|
41
|
+
sauce
|
42
|
+
setup
|
43
|
+
smoketest
|
44
|
+
testinstall
|
45
|
+
testproject
|
46
|
+
update
|
47
|
+
validate_service
|
48
|
+
-v
|
49
|
+
version
|
50
|
+
]
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
def execute!
|
55
|
+
case @command
|
56
|
+
when 'create_update_task'
|
57
|
+
create_update_task
|
58
|
+
when 'generate_npp_plugin'
|
59
|
+
generate_npp_plugin
|
60
|
+
when 'generate_registries'
|
61
|
+
generate_registries
|
62
|
+
when 'help'
|
63
|
+
puts help_text
|
64
|
+
when 'init'
|
65
|
+
initialize_project_in
|
66
|
+
when 'new'
|
67
|
+
create_new_project
|
68
|
+
when 'parallel'
|
69
|
+
run_in_parallel
|
70
|
+
when 'run'
|
71
|
+
run_as_cucumber
|
72
|
+
when 'run_feature'
|
73
|
+
run_feature
|
74
|
+
when 'setup'
|
75
|
+
setup_SimpliTest
|
76
|
+
when 'smoketest'
|
77
|
+
perform_smoke_test
|
78
|
+
when 'testinstall'
|
79
|
+
run_as_rake
|
80
|
+
when 'testproject'
|
81
|
+
testproject
|
82
|
+
when 'update'
|
83
|
+
`gem update SimpliTest`
|
84
|
+
when 'validate_service'
|
85
|
+
validate_service
|
86
|
+
when '-v', 'version'
|
87
|
+
puts "SimpliTest: v#{SimpliTest::VERSION}"
|
88
|
+
when '',nil
|
89
|
+
alert(framework_correctly_installed_message)
|
90
|
+
else
|
91
|
+
if @valid_commands.include?(@command)
|
92
|
+
alert "This feature has been deprecated. Please see the documentation folder in your project for help"
|
93
|
+
else
|
94
|
+
alert "You entered an invalid command"
|
95
|
+
end
|
96
|
+
@kernel.exit(0)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
=begin
|
100
|
+
*********************************************-------------------****************************************************************************
|
101
|
+
********************************************| CUCUMBER COMMANDS |***************************************************************************
|
102
|
+
*********************************************-------------------****************************************************************************
|
103
|
+
=end
|
104
|
+
|
105
|
+
|
106
|
+
def run_as_cucumber(args = @arguments.dup, verify_file_exists=false)
|
107
|
+
if verify_file_exists
|
108
|
+
unless File.exists? args.first
|
109
|
+
alert "#{args.first} File was Not Found. Could not run tests"
|
110
|
+
raise "FileNotFoundError"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
@project_path ||= project_path_for(@pwd)
|
114
|
+
runtime = prepare_runtime
|
115
|
+
run_dir = @project_path
|
116
|
+
Dir.chdir(run_dir)
|
117
|
+
Cucumber::Cli::Main.new(args).execute!(runtime)
|
118
|
+
end
|
119
|
+
|
120
|
+
def run_in_parallel
|
121
|
+
raise "Parallelization is not supported on Windows" if windows?
|
122
|
+
begin
|
123
|
+
`parallel_cucumber features`
|
124
|
+
rescue Exception => e
|
125
|
+
message = "There was a problem running tests in parallel"
|
126
|
+
alert message
|
127
|
+
puts e.message
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def prepare_runtime
|
132
|
+
require 'cucumber'
|
133
|
+
runtime = Cucumber::Runtime.new
|
134
|
+
runtime.load_programming_language('rb')
|
135
|
+
runtime
|
136
|
+
end
|
137
|
+
|
138
|
+
def perform_smoke_test
|
139
|
+
@project_path ||= project_path_for(@pwd)
|
140
|
+
smoke_test = File.join(@project_path, 'features', 'specifications', 'SmokeTest')
|
141
|
+
run_as_cucumber([smoke_test], true)
|
142
|
+
end
|
143
|
+
|
144
|
+
def perform_focus_test
|
145
|
+
focus_path = File.join(project_path_for(@pwd), 'features', 'specifications', 'Focus')
|
146
|
+
run_as_cucumber([focus_path], true)
|
147
|
+
end
|
148
|
+
|
149
|
+
def testproject
|
150
|
+
#TODO: Write a utility that verifies project configuration. See list below:
|
151
|
+
#YAML errors in config files
|
152
|
+
#Missing Files
|
153
|
+
#Access to Gem Step definitions
|
154
|
+
#Basically anything the user can break by changing something in the test project
|
155
|
+
@project_path ||= project_path_for(@pwd)
|
156
|
+
Dir.chdir @project_path
|
157
|
+
begin
|
158
|
+
`cucumber --dry-run`
|
159
|
+
alert('Finished checking the project. If you do not see any errors on the command prompt..you are good to go')
|
160
|
+
rescue Exception => e
|
161
|
+
message = "It seems that your project directory is corrupted \n It maybe possible for you to simply generate a new project and copy your test cases over. "
|
162
|
+
alert(message)
|
163
|
+
puts e.message
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
def run_feature
|
169
|
+
feature = @arguments.first
|
170
|
+
feature = File.exists?(feature) ? feature : File.join(project_path_for(@pwd), 'features', 'specifications', feature)
|
171
|
+
run_as_cucumber([feature], true)
|
172
|
+
end
|
173
|
+
=begin
|
174
|
+
*********************************************-------------------****************************************************************************
|
175
|
+
********************************************| CUCUMBER COMMANDS |***************************************************************************
|
176
|
+
*********************************************-------------------****************************************************************************
|
177
|
+
=end
|
178
|
+
|
179
|
+
=begin
|
180
|
+
*********************************************-------------------****************************************************************************
|
181
|
+
********************************************| PROJECT SETUP |***************************************************************************
|
182
|
+
*********************************************-------------------****************************************************************************
|
183
|
+
=end
|
184
|
+
|
185
|
+
## Invoked with SimpliTest new <project name>
|
186
|
+
## Creates a new example project with the <project name> with sample test cases and documentation
|
187
|
+
def create_new_project
|
188
|
+
if user_consents?
|
189
|
+
unless project_exists_in?(@pwd)
|
190
|
+
new_dir_name = @arguments.join(' ')
|
191
|
+
new_dir_path = (File.join(@pwd, new_dir_name))
|
192
|
+
make_directory(new_dir_path)
|
193
|
+
initialize_project_in(new_dir_path, true)
|
194
|
+
else
|
195
|
+
alert "You cant create a project inside an existing project!"
|
196
|
+
end
|
197
|
+
else
|
198
|
+
alert abort_message
|
199
|
+
end
|
200
|
+
end
|
201
|
+
## Invoked inside a directory with SimpliTest init
|
202
|
+
## Creates a new SimpliTest project within the current directory
|
203
|
+
# @param target_directory
|
204
|
+
# @param user_has_consented (true if user types or clicks yes)
|
205
|
+
def initialize_project_in(target_directory=@pwd, user_has_consented=false)
|
206
|
+
if (user_has_consented|| user_consents?)
|
207
|
+
if (project_exists_in?(target_directory))
|
208
|
+
alert directory_exists_message
|
209
|
+
else
|
210
|
+
project_template_dir = template_path_to 'NewSimpliTestProject'
|
211
|
+
FileUtils.cp_r(Dir[File.join(project_template_dir, '*')], target_directory)
|
212
|
+
alert("Successfully Initialized Project!")
|
213
|
+
end
|
214
|
+
else
|
215
|
+
alert abort_message
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
=begin
|
220
|
+
*********************************************-------------------****************************************************************************
|
221
|
+
********************************************| PROJECT SETUP |***************************************************************************
|
222
|
+
*********************************************-------------------****************************************************************************
|
223
|
+
=end
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
=begin
|
228
|
+
*********************************************-------------------****************************************************************************
|
229
|
+
********************************************| DATA VALIDATION |***************************************************************************
|
230
|
+
*********************************************-------------------****************************************************************************
|
231
|
+
=end
|
232
|
+
|
233
|
+
def validate_service
|
234
|
+
args = @arguments.dup
|
235
|
+
load_db_options
|
236
|
+
if args.empty?
|
237
|
+
validate_all_services
|
238
|
+
else
|
239
|
+
args.each do |service_name|
|
240
|
+
validate_service_by_name(service_name)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def load_db_options
|
246
|
+
require 'tiny_tds'
|
247
|
+
require 'csv'
|
248
|
+
extend DataValidationHelpers
|
249
|
+
@project_path ||= project_path_for(@pwd)
|
250
|
+
database_config = File.join(@project_path, 'features', 'support', 'config', 'database.yml')
|
251
|
+
options = YAML.load(File.read(database_config))
|
252
|
+
@db = TinyTds::Client.new(options)
|
253
|
+
end
|
254
|
+
|
255
|
+
def validate_all_services
|
256
|
+
services_dir_glob_pattern = File.join(@project_path, 'data', '*', File::SEPARATOR)
|
257
|
+
services = Dir.glob(services_dir_glob_pattern).collect{|k| k.split(File::SEPARATOR).last}
|
258
|
+
services.each do |service|
|
259
|
+
puts "Running Test for: #{service}"
|
260
|
+
validate_service_by_name service
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def validate_service_by_name(name)
|
265
|
+
service_config_dir = File.join(@project_path, 'data', name)
|
266
|
+
variables_file = File.join(service_config_dir, 'variables.csv')
|
267
|
+
variables_csv = CSV.read(variables_file, :headers => true)
|
268
|
+
variables_hash = variables_csv.reject{|r| r.empty?}.map {|r| r.to_hash }
|
269
|
+
variables_hash.each do |set|
|
270
|
+
validate_service_against(@db, service_config_dir, set)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
=begin
|
275
|
+
*********************************************-------------------****************************************************************************
|
276
|
+
********************************************| DATA VALIDATION |***************************************************************************
|
277
|
+
*********************************************-------------------****************************************************************************
|
278
|
+
=end
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
def run_as_rake(from_dir=@pwd)
|
285
|
+
require 'rake'
|
286
|
+
require 'pp'
|
287
|
+
Dir.chdir(@gem_dir) # We'll load rakefile from the gem's dir.
|
288
|
+
Rake.application.init
|
289
|
+
Rake.application.load_rakefile
|
290
|
+
Dir.chdir(from_dir)
|
291
|
+
Rake.application.invoke_task(@command)
|
292
|
+
end
|
293
|
+
|
294
|
+
def help_text
|
295
|
+
#TODO: Write a man page
|
296
|
+
%Q(Usage: SimpliTest [options]
|
297
|
+
|
298
|
+
Examples:
|
299
|
+
SimpliTest run features/specifications/test.feature 'run just the give one
|
300
|
+
SimpliTest run --tags @tests 'runs all with the @tests tag
|
301
|
+
SimpliTest run ' runs all of them
|
302
|
+
|
303
|
+
Options:
|
304
|
+
help - This screen
|
305
|
+
version - Version
|
306
|
+
init - Initialize this directory as a project workspace for SimpliTest
|
307
|
+
new <directory name> - Create a new SimpliTest project within directory provided
|
308
|
+
run <file path> <cucumber flags> - Run a feature also pass any cucumber flags, see cucumber --help
|
309
|
+
)
|
310
|
+
# create_update_task
|
311
|
+
# document
|
312
|
+
# document[csv]
|
313
|
+
# document[html]
|
314
|
+
# focustest
|
315
|
+
# generate_npp_plugin
|
316
|
+
# generate_registries
|
317
|
+
# parallel
|
318
|
+
# run_feature
|
319
|
+
# sauce
|
320
|
+
# setup
|
321
|
+
# smoketest
|
322
|
+
# testinstall
|
323
|
+
# testproject
|
324
|
+
# update
|
325
|
+
# validate_service
|
326
|
+
end
|
327
|
+
|
328
|
+
end #end self << class. Any methods below this are instance methods
|
329
|
+
end#end Main
|
330
|
+
end#end Cli
|
331
|
+
end#end SimpliTest
|
332
|
+
|
333
|
+
|