cucumber_analytics 0.0.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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.rdoc +76 -0
- data/Rakefile +2 -0
- data/cucumber_analytics.gemspec +22 -0
- data/features/analysis/feature_collection.feature +39 -0
- data/features/analysis/feature_file_collection.feature +36 -0
- data/features/analysis/step_collection.feature +137 -0
- data/features/analysis/tag_collection.feature +91 -0
- data/features/analysis/test_collection.feature +69 -0
- data/features/analysis/test_comparison.feature +123 -0
- data/features/modeling/background_modeling.feature +147 -0
- data/features/modeling/directory_modeling.feature +86 -0
- data/features/modeling/feature_file_modeling.feature +37 -0
- data/features/modeling/feature_modeling.feature +163 -0
- data/features/modeling/outline_modeling.feature +186 -0
- data/features/modeling/scenario_modeling.feature +154 -0
- data/features/step_definitions/background_steps.rb +55 -0
- data/features/step_definitions/directory_steps.rb +20 -0
- data/features/step_definitions/feature_steps.rb +62 -0
- data/features/step_definitions/file_steps.rb +18 -0
- data/features/step_definitions/outline_steps.rb +26 -0
- data/features/step_definitions/setup_steps.rb +50 -0
- data/features/step_definitions/test_steps.rb +82 -0
- data/features/step_definitions/world_steps.rb +158 -0
- data/features/support/env.rb +29 -0
- data/features/support/transforms.rb +3 -0
- data/lib/cucumber_analytics/feature_element.rb +54 -0
- data/lib/cucumber_analytics/outline_example.rb +31 -0
- data/lib/cucumber_analytics/parsed_background.rb +23 -0
- data/lib/cucumber_analytics/parsed_directory.rb +56 -0
- data/lib/cucumber_analytics/parsed_feature.rb +70 -0
- data/lib/cucumber_analytics/parsed_file.rb +140 -0
- data/lib/cucumber_analytics/parsed_scenario.rb +29 -0
- data/lib/cucumber_analytics/parsed_scenario_outline.rb +57 -0
- data/lib/cucumber_analytics/step.rb +81 -0
- data/lib/cucumber_analytics/test_element.rb +93 -0
- data/lib/cucumber_analytics/version.rb +3 -0
- data/lib/cucumber_analytics/world.rb +182 -0
- data/lib/cucumber_analytics.rb +12 -0
- metadata +174 -0
@@ -0,0 +1,154 @@
|
|
1
|
+
Feature: Scenario elements can be modeled.
|
2
|
+
|
3
|
+
|
4
|
+
Acceptance criteria
|
5
|
+
|
6
|
+
All conceptual pieces of a Scenario can be modeled:
|
7
|
+
1. the scenario's name
|
8
|
+
2. the scenario's description
|
9
|
+
3. the scenario's steps
|
10
|
+
4. the scenario's tags
|
11
|
+
|
12
|
+
|
13
|
+
Background: Test file setup.
|
14
|
+
Given the following feature file:
|
15
|
+
"""
|
16
|
+
@a_feature_level_tag
|
17
|
+
Feature: The test feature name.
|
18
|
+
Some more feature description.
|
19
|
+
|
20
|
+
@a_tag
|
21
|
+
|
22
|
+
@another_tag@yet_another_tag
|
23
|
+
Scenario: The first scenario's name.
|
24
|
+
#a comment
|
25
|
+
|
26
|
+
Some text describing the scenario.
|
27
|
+
More text.
|
28
|
+
Given this *parameterized* step takes a table:
|
29
|
+
| data |
|
30
|
+
| more data |
|
31
|
+
And some setup step
|
32
|
+
#
|
33
|
+
When a step with a *parameter*
|
34
|
+
And a big step:
|
35
|
+
#random comment
|
36
|
+
\"\"\"
|
37
|
+
some text
|
38
|
+
|
39
|
+
#some comments
|
40
|
+
Scenario:
|
41
|
+
Scenario Outline:
|
42
|
+
Examples:
|
43
|
+
@
|
44
|
+
Feature:
|
45
|
+
|
|
46
|
+
Given
|
47
|
+
When
|
48
|
+
Then
|
49
|
+
*
|
50
|
+
some more text
|
51
|
+
\"\"\"
|
52
|
+
Then *lots* *of* *parameters*
|
53
|
+
|
54
|
+
"""
|
55
|
+
And parameter delimiters of "*" and "*"
|
56
|
+
When the file is read
|
57
|
+
|
58
|
+
|
59
|
+
Scenario: The scenario name is modeled.
|
60
|
+
Then the test is found to have the following properties:
|
61
|
+
| name | The first scenario's name. |
|
62
|
+
|
63
|
+
Scenario: The scenario description is modeled.
|
64
|
+
Then the test descriptive lines are as follows:
|
65
|
+
| Some text describing the scenario. |
|
66
|
+
| More text. |
|
67
|
+
|
68
|
+
Scenario: The scenario steps are modeled.
|
69
|
+
Then the test steps are as follows:
|
70
|
+
| Given this *parameterized* step takes a table: |
|
71
|
+
| \| data \| |
|
72
|
+
| \| more data \| |
|
73
|
+
| And some setup step |
|
74
|
+
| When a step with a *parameter* |
|
75
|
+
| And a big step: |
|
76
|
+
| """ |
|
77
|
+
| 'some text' |
|
78
|
+
| '' |
|
79
|
+
| '#some comments' |
|
80
|
+
| 'Scenario:' |
|
81
|
+
| 'Scenario Outline:' |
|
82
|
+
| 'Examples:' |
|
83
|
+
| '@' |
|
84
|
+
| 'Feature:' |
|
85
|
+
| '\|' |
|
86
|
+
| 'Given' |
|
87
|
+
| 'When' |
|
88
|
+
| 'Then' |
|
89
|
+
| '*' |
|
90
|
+
| ' some more text' |
|
91
|
+
| """ |
|
92
|
+
| Then *lots* *of* *parameters* |
|
93
|
+
And the test steps "without" arguments are as follows:
|
94
|
+
| Given this ** step takes a table: |
|
95
|
+
| And some setup step |
|
96
|
+
| When a step with a ** |
|
97
|
+
| And a big step: |
|
98
|
+
| Then ** ** ** |
|
99
|
+
And the test steps "without" keywords are as follows:
|
100
|
+
| this *parameterized* step takes a table: |
|
101
|
+
| \| data \| |
|
102
|
+
| \| more data \| |
|
103
|
+
| some setup step |
|
104
|
+
| a step with a *parameter* |
|
105
|
+
| a big step: |
|
106
|
+
| """ |
|
107
|
+
| 'some text' |
|
108
|
+
| '' |
|
109
|
+
| '#some comments' |
|
110
|
+
| 'Scenario:' |
|
111
|
+
| 'Scenario Outline:' |
|
112
|
+
| 'Examples:' |
|
113
|
+
| '@' |
|
114
|
+
| 'Feature:' |
|
115
|
+
| '\|' |
|
116
|
+
| 'Given' |
|
117
|
+
| 'When' |
|
118
|
+
| 'Then' |
|
119
|
+
| '*' |
|
120
|
+
| ' some more text' |
|
121
|
+
| """ |
|
122
|
+
| *lots* *of* *parameters* |
|
123
|
+
And the test steps "without" arguments "without" keywords are as follows:
|
124
|
+
| this ** step takes a table: |
|
125
|
+
| some setup step |
|
126
|
+
| a step with a ** |
|
127
|
+
| a big step: |
|
128
|
+
| ** ** ** |
|
129
|
+
And the test step "1" has the following block:
|
130
|
+
| \| data \| |
|
131
|
+
| \| more data \| |
|
132
|
+
And the test step "4" has the following block:
|
133
|
+
| """ |
|
134
|
+
| 'some text' |
|
135
|
+
| '' |
|
136
|
+
| '#some comments' |
|
137
|
+
| 'Scenario:' |
|
138
|
+
| 'Scenario Outline:' |
|
139
|
+
| 'Examples:' |
|
140
|
+
| '@' |
|
141
|
+
| 'Feature:' |
|
142
|
+
| '\|' |
|
143
|
+
| 'Given' |
|
144
|
+
| 'When' |
|
145
|
+
| 'Then' |
|
146
|
+
| '*' |
|
147
|
+
| ' some more text' |
|
148
|
+
| """ |
|
149
|
+
|
150
|
+
Scenario: The scenario tags are modeled.
|
151
|
+
Then the test is found to have the following tags:
|
152
|
+
| @a_tag |
|
153
|
+
| @another_tag |
|
154
|
+
| @yet_another_tag |
|
@@ -0,0 +1,55 @@
|
|
1
|
+
Then /^the(?: feature "([^"]*)")? background is found to have the following properties:$/ do |file, properties|
|
2
|
+
file ||= 1
|
3
|
+
properties = properties.rows_hash
|
4
|
+
|
5
|
+
properties.each do |property, expected_value|
|
6
|
+
assert { expected_value == @parsed_files[file - 1].feature.background.send(property.to_sym).to_s }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
Then /^the(?: feature "([^"]*)")? background's descriptive lines are as follows:$/ do |file, lines|
|
11
|
+
file ||= 1
|
12
|
+
expected_description = lines.raw.flatten
|
13
|
+
|
14
|
+
assert { @parsed_files[file - 1].feature.background.description == expected_description }
|
15
|
+
end
|
16
|
+
|
17
|
+
Then /^the(?: feature "([^"]*)")? background's steps(?: "([^"]*)" arguments)?(?: "([^"]*)" keywords)? are as follows:$/ do |file, arguments, keywords, steps|
|
18
|
+
file ||= 1
|
19
|
+
arguments ||= 'with'
|
20
|
+
keywords ||= 'with'
|
21
|
+
translate = {'with' => true,
|
22
|
+
'without' => false}
|
23
|
+
|
24
|
+
options = {:with_keywords => translate[keywords], :with_arguments => translate[arguments]}
|
25
|
+
|
26
|
+
steps = steps.raw.flatten.collect do |step|
|
27
|
+
if step.start_with? "'"
|
28
|
+
step.slice(1..step.length - 2)
|
29
|
+
else
|
30
|
+
step
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
actual_steps = Array.new.tap do |steps|
|
35
|
+
@parsed_files[file - 1].feature.background.steps.each do |step|
|
36
|
+
steps << step.step_text(options)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
assert { actual_steps.flatten == steps }
|
41
|
+
end
|
42
|
+
|
43
|
+
When /^step "([^"]*)" of the background (?:of feature "([^"]*)" )?has the following block:$/ do |step, file, block|
|
44
|
+
file ||= 1
|
45
|
+
|
46
|
+
block = block.raw.flatten.collect do |line|
|
47
|
+
if line.start_with? "'"
|
48
|
+
line.slice(1..line.length - 2)
|
49
|
+
else
|
50
|
+
line
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
assert { @parsed_files[file - 1].feature.background.steps[step - 1].block == block }
|
55
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Then /^(?:the )?directory(?: "([^"]*)")? is found to have the following properties:$/ do |directory, properties|
|
2
|
+
directory ||= 1
|
3
|
+
properties = properties.rows_hash
|
4
|
+
|
5
|
+
properties.each do |property, expected_value|
|
6
|
+
if property == 'path'
|
7
|
+
expected_value.sub!('path_to', @default_file_directory)
|
8
|
+
end
|
9
|
+
|
10
|
+
assert { expected_value == @parsed_directories[directory - 1].send(property.to_sym).to_s }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^(?:the )?directory(?: "([^"]*)")? feature files are as follows:$/ do |directory, files|
|
15
|
+
directory ||= 1
|
16
|
+
|
17
|
+
actual_files = @parsed_directories[directory - 1].feature_files.collect { |file| file.name }
|
18
|
+
|
19
|
+
assert { actual_files.flatten.sort == files.raw.flatten.sort }
|
20
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
Then /^(?:the )?feature(?: "([^"]*)")? is found to have the following properties:$/ do |file, properties|
|
2
|
+
file ||= 1
|
3
|
+
properties = properties.rows_hash
|
4
|
+
|
5
|
+
properties.each do |property, expected_value|
|
6
|
+
assert { expected_value == @parsed_files[file - 1].feature.send(property.to_sym).to_s }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
Then /^the descriptive lines of feature "([^"]*)" are as follows:$/ do |file, lines|
|
11
|
+
expected_description = lines.raw.flatten
|
12
|
+
|
13
|
+
assert { @parsed_files[file - 1].feature.description == expected_description }
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^feature "([^"]*)" is found to have the following tags:$/ do |file, tags|
|
17
|
+
expected_tags = tags.raw.flatten
|
18
|
+
|
19
|
+
assert { @parsed_files[file - 1].feature.tags == expected_tags }
|
20
|
+
end
|
21
|
+
|
22
|
+
Then /^feature "([^"]*)" has no descriptive lines$/ do |file|
|
23
|
+
assert { @parsed_files[file - 1].feature.description == [] }
|
24
|
+
end
|
25
|
+
|
26
|
+
Then /^feature "([^"]*)" has no tags$/ do |file|
|
27
|
+
assert { @parsed_files[file - 1].feature.tags == [] }
|
28
|
+
end
|
29
|
+
|
30
|
+
When /^(?:the )?feature(?: "([^"]*)")? scenarios are as follows:$/ do |file, scenarios|
|
31
|
+
file ||= 1
|
32
|
+
|
33
|
+
actual_scenarios = @parsed_files[file - 1].feature.scenarios.collect { |scenario| scenario.name }
|
34
|
+
|
35
|
+
assert { actual_scenarios.flatten.sort == scenarios.raw.flatten.sort }
|
36
|
+
end
|
37
|
+
|
38
|
+
When /^(?:the )?feature(?: "([^"]*)")? outlines are as follows:$/ do |file, outlines|
|
39
|
+
file ||= 1
|
40
|
+
|
41
|
+
actual_outlines = @parsed_files[file - 1].feature.outlines.collect { |outline| outline.name }
|
42
|
+
|
43
|
+
assert { actual_outlines.flatten.sort == outlines.raw.flatten.sort }
|
44
|
+
end
|
45
|
+
|
46
|
+
When /^(?:the )?feature(?: "([^"]*)")? background is as follows:$/ do |file, background|
|
47
|
+
file ||= 1
|
48
|
+
|
49
|
+
assert { @parsed_files[file - 1].feature.background.name == background.raw.flatten.first }
|
50
|
+
end
|
51
|
+
|
52
|
+
When /^feature "([^"]*)" has no scenarios$/ do |file|
|
53
|
+
assert { @parsed_files[file - 1].feature.scenarios == [] }
|
54
|
+
end
|
55
|
+
|
56
|
+
When /^feature "([^"]*)" has no outlines/ do |file|
|
57
|
+
assert { @parsed_files[file - 1].feature.outlines == [] }
|
58
|
+
end
|
59
|
+
|
60
|
+
When /^feature "([^"]*)" has no background/ do |file|
|
61
|
+
assert { @parsed_files[file - 1].feature.has_background? == false }
|
62
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Then /^(?:the )?file(?: "([^"]*)")? is found to have the following properties:$/ do |file, properties|
|
2
|
+
file ||= 1
|
3
|
+
properties = properties.rows_hash
|
4
|
+
|
5
|
+
properties.each do |property, expected_value|
|
6
|
+
if property == 'path'
|
7
|
+
expected_value.sub!('path_to', @test_directory)
|
8
|
+
end
|
9
|
+
|
10
|
+
assert { expected_value == @parsed_files[file - 1].send(property.to_sym).to_s }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^(?:the )?file(?: "([^"]*)")? features are as follows:$/ do |file, feature|
|
15
|
+
file ||= 1
|
16
|
+
|
17
|
+
assert { @parsed_files[file - 1].feature.name == feature.raw.flatten.first }
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Then /^(?:feature "([^"]*)" )?"([^"]*)" example "([^"]*)" has a "([^"]*)"$/ do |file, test, example, name|
|
2
|
+
file ||= 1
|
3
|
+
|
4
|
+
assert { @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].name == name }
|
5
|
+
end
|
6
|
+
|
7
|
+
When /^(?:feature "([^"]*)" )?"([^"]*)" example "([^"]*)" descriptive lines are as follows:$/ do |file, test, example, lines|
|
8
|
+
file ||= 1
|
9
|
+
lines = lines.raw.flatten.delete_if { |line| line == '' }
|
10
|
+
|
11
|
+
assert { @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].description == lines }
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^(?:feature "([^"]*)" )?"([^"]*)" example "([^"]*)" tags are as follows:$/ do |file, test, example, tags|
|
15
|
+
file ||= 1
|
16
|
+
tags = tags.raw.flatten.delete_if { |line| line == '' }
|
17
|
+
|
18
|
+
assert { @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].tags == tags }
|
19
|
+
end
|
20
|
+
|
21
|
+
When /^(?:feature "([^"]*)" )?"([^"]*)" example "([^"]*)" rows are as follows:$/ do |file, test, example, rows|
|
22
|
+
file ||= 1
|
23
|
+
rows = rows.raw.flatten
|
24
|
+
|
25
|
+
assert { @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].rows == rows }
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
Given /^the following(?: feature)? file(?: "([^"]*)")?:$/ do |file_name, file_text|
|
2
|
+
@test_directory ||= @default_file_directory
|
3
|
+
file_name ||= @default_feature_file_name
|
4
|
+
|
5
|
+
File.open("#{@test_directory}/#{file_name}", 'w') { |file|
|
6
|
+
file.write(file_text)
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^the file(?: "([^"]*)")? is read$/ do |file_name|
|
11
|
+
@parsed_files ||= []
|
12
|
+
@test_directory ||= @default_file_directory
|
13
|
+
file_name ||= @default_feature_file_name
|
14
|
+
|
15
|
+
@parsed_files << CucumberAnalytics::ParsedFile.new("#{@test_directory}/#{file_name}")
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^the step definition file "([^"]*)" is read$/ do |file_name|
|
19
|
+
@test_directory ||= @default_file_directory
|
20
|
+
file_name ||= @default_step_file_name
|
21
|
+
|
22
|
+
CucumberAnalytics::World.load_step_file("#{@test_directory}/#{file_name}")
|
23
|
+
end
|
24
|
+
|
25
|
+
When /^parameter delimiters of "([^"]*)" and "([^"]*)"$/ do |left_delimiter, right_delimiter|
|
26
|
+
CucumberAnalytics::World.left_delimiter = left_delimiter
|
27
|
+
CucumberAnalytics::World.right_delimiter = right_delimiter
|
28
|
+
end
|
29
|
+
|
30
|
+
Given /^a directory "([^"]*)"$/ do |directory_name|
|
31
|
+
@test_directory = "#{@default_file_directory}/#{directory_name}"
|
32
|
+
|
33
|
+
FileUtils.mkdir(@test_directory) unless File.exists?(@test_directory)
|
34
|
+
end
|
35
|
+
|
36
|
+
When /^the directory(?: "([^"]*)")? is read$/ do |directory_name|
|
37
|
+
@parsed_directories ||= []
|
38
|
+
@test_directory = "#{@default_file_directory}/#{directory_name}" if directory_name
|
39
|
+
|
40
|
+
@parsed_directories << CucumberAnalytics::ParsedDirectory.new(@test_directory)
|
41
|
+
end
|
42
|
+
|
43
|
+
When /^the following step definition file(?: "([^"]*)")?:$/ do |file_name, file_text|
|
44
|
+
@test_directory ||= @default_file_directory
|
45
|
+
file_name ||= @default_step_file_name
|
46
|
+
|
47
|
+
File.open("#{@test_directory}/#{file_name}", 'w') { |file|
|
48
|
+
file.write(file_text)
|
49
|
+
}
|
50
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is found to have the following properties:$/ do |file, test, properties|
|
2
|
+
file ||= 1
|
3
|
+
test ||= 1
|
4
|
+
|
5
|
+
properties = properties.rows_hash
|
6
|
+
|
7
|
+
properties.each do |property, value|
|
8
|
+
assert { value == @parsed_files[file - 1].feature.tests[test - 1].send(property.to_sym).to_s }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? descriptive lines are as follows:$/ do |file, test, lines|
|
13
|
+
file ||= 1
|
14
|
+
test ||= 1
|
15
|
+
lines = lines.raw.flatten
|
16
|
+
|
17
|
+
assert { @parsed_files[file - 1].feature.tests[test - 1].description == lines }
|
18
|
+
end
|
19
|
+
|
20
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? steps(?: "([^"]*)" arguments)?(?: "([^"]*)" keywords)? are as follows:$/ do |file, test, arguments, keywords, steps|
|
21
|
+
file ||= 1
|
22
|
+
test ||= 1
|
23
|
+
arguments ||= 'with'
|
24
|
+
keywords ||= 'with'
|
25
|
+
translate = {'with' => true,
|
26
|
+
'without' => false}
|
27
|
+
|
28
|
+
options = {:with_keywords => translate[keywords], :with_arguments => translate[arguments]}
|
29
|
+
|
30
|
+
|
31
|
+
steps = steps.raw.flatten.collect do |step|
|
32
|
+
if step.start_with? "'"
|
33
|
+
step.slice(1..step.length - 2)
|
34
|
+
else
|
35
|
+
step
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
actual_steps = Array.new.tap do |steps|
|
40
|
+
@parsed_files[file - 1].feature.tests[test - 1].steps.each do |step|
|
41
|
+
steps << step.step_text(options)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
assert { actual_steps.flatten == steps }
|
46
|
+
end
|
47
|
+
|
48
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is found to have the following tags:$/ do |file, test, tags|
|
49
|
+
file ||= 1
|
50
|
+
test ||= 1
|
51
|
+
|
52
|
+
assert { @parsed_files[file - 1].feature.tests[test - 1].tags == tags.raw.flatten }
|
53
|
+
end
|
54
|
+
|
55
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step "([^"]*)" has the following block:$/ do |file, test, step, block|
|
56
|
+
file ||= 1
|
57
|
+
test ||= 1
|
58
|
+
|
59
|
+
block = block.raw.flatten.collect do |line|
|
60
|
+
if line.start_with? "'"
|
61
|
+
line.slice(1..line.length - 2)
|
62
|
+
else
|
63
|
+
line
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
assert { @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block == block }
|
68
|
+
end
|
69
|
+
|
70
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is equal to test "([^"]*)"$/ do |file, first_test, second_test|
|
71
|
+
file ||= 1
|
72
|
+
first_test ||= 1
|
73
|
+
|
74
|
+
assert { @parsed_files[file - 1].feature.tests[first_test - 1] == @parsed_files[file - 1].feature.tests[second_test - 1] }
|
75
|
+
end
|
76
|
+
|
77
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? is not equal to test "([^"]*)"$/ do |file, first_test, second_test|
|
78
|
+
file ||= 1
|
79
|
+
first_test ||= 1
|
80
|
+
|
81
|
+
assert { @parsed_files[file - 1].feature.tests[first_test - 1] != @parsed_files[file - 1].feature.tests[second_test - 1] }
|
82
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
Then /^the tags collected from (?:feature "([^"]*)" )?test "([^"]*)" are as follows:$/ do |file, test, tags|
|
2
|
+
file ||= 1
|
3
|
+
tags = tags.raw.flatten
|
4
|
+
|
5
|
+
assert { CucumberAnalytics::World.tags_in(@parsed_files[file - 1].feature.tests[test - 1]).sort == tags.sort }
|
6
|
+
end
|
7
|
+
|
8
|
+
Then /^the tags collected from feature "([^"]*)" are as follows:$/ do |file, tags|
|
9
|
+
file ||= 1
|
10
|
+
tags = tags.raw.flatten
|
11
|
+
|
12
|
+
assert { CucumberAnalytics::World.tags_in(@parsed_files[file - 1].feature).sort == tags.sort }
|
13
|
+
end
|
14
|
+
|
15
|
+
Then /^the tags collected from file "([^"]*)" are as follows:$/ do |file, tags|
|
16
|
+
file ||= 1
|
17
|
+
tags = tags.raw.flatten
|
18
|
+
|
19
|
+
assert { CucumberAnalytics::World.tags_in(@parsed_files[file - 1]).sort == tags.sort }
|
20
|
+
end
|
21
|
+
|
22
|
+
Then /^the tags collected from directory are as follows:$/ do |tags|
|
23
|
+
tags = tags.raw.flatten
|
24
|
+
|
25
|
+
assert { CucumberAnalytics::World.tags_in(@parsed_directories.last).sort == tags.sort }
|
26
|
+
end
|
27
|
+
|
28
|
+
Then /^the(?: "([^"]*)")? steps collected from feature "([^"]*)" background are as follows:$/ do |defined, file, steps|
|
29
|
+
file ||= 1
|
30
|
+
steps = steps.raw.flatten
|
31
|
+
container = @parsed_files[file - 1].feature.background
|
32
|
+
|
33
|
+
case defined
|
34
|
+
when 'defined'
|
35
|
+
expected_steps = CucumberAnalytics::World.defined_steps_in(container)
|
36
|
+
when 'undefined'
|
37
|
+
expected_steps = CucumberAnalytics::World.undefined_steps_in(container)
|
38
|
+
else
|
39
|
+
expected_steps = CucumberAnalytics::World.steps_in(container)
|
40
|
+
end
|
41
|
+
|
42
|
+
assert { expected_steps.collect { |step| step.step_text }.flatten.sort == steps.sort }
|
43
|
+
end
|
44
|
+
|
45
|
+
Then /^the(?: "([^"]*)")? steps collected from feature "([^"]*)" test "([^"]*)" are as follows:$/ do |defined, file, test, steps|
|
46
|
+
file ||= 1
|
47
|
+
steps = steps.raw.flatten
|
48
|
+
container = @parsed_files[file - 1].feature.tests[test - 1]
|
49
|
+
|
50
|
+
case defined
|
51
|
+
when 'defined'
|
52
|
+
expected_steps = CucumberAnalytics::World.defined_steps_in(container)
|
53
|
+
when 'undefined'
|
54
|
+
expected_steps = CucumberAnalytics::World.undefined_steps_in(container)
|
55
|
+
else
|
56
|
+
expected_steps = CucumberAnalytics::World.steps_in(container)
|
57
|
+
end
|
58
|
+
|
59
|
+
assert { expected_steps.collect { |step| step.step_text }.flatten.sort == steps.sort }
|
60
|
+
end
|
61
|
+
|
62
|
+
When /^the(?: "([^"]*)")? steps collected from (?:the )?feature(?: "([^"]*)")? are as follows:$/ do |defined, file, steps|
|
63
|
+
file ||= 1
|
64
|
+
steps = steps.raw.flatten
|
65
|
+
container = @parsed_files[file - 1].feature
|
66
|
+
|
67
|
+
case defined
|
68
|
+
when 'defined'
|
69
|
+
expected_steps = CucumberAnalytics::World.defined_steps_in(container)
|
70
|
+
when 'undefined'
|
71
|
+
expected_steps = CucumberAnalytics::World.undefined_steps_in(container)
|
72
|
+
else
|
73
|
+
expected_steps = CucumberAnalytics::World.steps_in(container)
|
74
|
+
end
|
75
|
+
|
76
|
+
assert { expected_steps.collect { |step| step.step_text }.flatten.sort == steps.sort }
|
77
|
+
end
|
78
|
+
|
79
|
+
When /^the(?: "([^"]*)")? steps collected from (?:the )?file(?: "([^"]*)")? are as follows:$/ do |defined, file, steps|
|
80
|
+
file ||= 1
|
81
|
+
steps = steps.raw.flatten
|
82
|
+
container = @parsed_files[file - 1]
|
83
|
+
|
84
|
+
case defined
|
85
|
+
when 'defined'
|
86
|
+
expected_steps = CucumberAnalytics::World.defined_steps_in(container)
|
87
|
+
when 'undefined'
|
88
|
+
expected_steps = CucumberAnalytics::World.undefined_steps_in(container)
|
89
|
+
else
|
90
|
+
expected_steps = CucumberAnalytics::World.steps_in(container)
|
91
|
+
end
|
92
|
+
|
93
|
+
assert { expected_steps.collect { |step| step.step_text }.flatten.sort == steps.sort }
|
94
|
+
end
|
95
|
+
|
96
|
+
When /^the(?: "([^"]*)")? steps collected from the directory are as follows:$/ do |defined, steps|
|
97
|
+
steps = steps.raw.flatten
|
98
|
+
container = @parsed_directories.last
|
99
|
+
|
100
|
+
case defined
|
101
|
+
when 'defined'
|
102
|
+
expected_steps = CucumberAnalytics::World.defined_steps_in(container)
|
103
|
+
when 'undefined'
|
104
|
+
expected_steps = CucumberAnalytics::World.undefined_steps_in(container)
|
105
|
+
else
|
106
|
+
expected_steps = CucumberAnalytics::World.steps_in(container)
|
107
|
+
end
|
108
|
+
|
109
|
+
assert { expected_steps.collect { |step| step.step_text }.flatten.sort == steps.sort }
|
110
|
+
end
|
111
|
+
|
112
|
+
Then /^the tests collected from feature "([^"]*)" are as follows:$/ do |file, tests|
|
113
|
+
file ||= 1
|
114
|
+
|
115
|
+
actual_tests = CucumberAnalytics::World.tests_in(@parsed_files[file - 1].feature).collect { |test| test.name }
|
116
|
+
|
117
|
+
assert { actual_tests.flatten.sort == tests.raw.flatten.sort }
|
118
|
+
end
|
119
|
+
|
120
|
+
Then /^the tests collected from file "([^"]*)" are as follows:$/ do |file, tests|
|
121
|
+
file ||= 1
|
122
|
+
|
123
|
+
actual_tests = CucumberAnalytics::World.tests_in(@parsed_files[file - 1]).collect { |test| test.name }
|
124
|
+
|
125
|
+
assert { actual_tests.flatten.sort == tests.raw.flatten.sort }
|
126
|
+
end
|
127
|
+
|
128
|
+
Then /^the tests collected from directory "([^"]*)" are as follows:$/ do |directory, tests|
|
129
|
+
directory ||= 1
|
130
|
+
|
131
|
+
actual_tests = CucumberAnalytics::World.tests_in(@parsed_directories[directory - 1]).collect { |test| test.name }
|
132
|
+
|
133
|
+
assert { actual_tests.flatten.sort == tests.raw.flatten.sort }
|
134
|
+
end
|
135
|
+
|
136
|
+
Then /^the features collected from file "([^"]*)" are as follows:$/ do |file, features|
|
137
|
+
file ||= 1
|
138
|
+
|
139
|
+
actual_features = CucumberAnalytics::World.features_in(@parsed_files[file - 1]).collect { |feature| feature.name }
|
140
|
+
|
141
|
+
assert { actual_features.flatten.sort == features.raw.flatten.sort }
|
142
|
+
end
|
143
|
+
|
144
|
+
Then /^the features collected from directory "([^"]*)" are as follows:$/ do |directory, features|
|
145
|
+
directory ||= 1
|
146
|
+
|
147
|
+
actual_features = CucumberAnalytics::World.features_in(@parsed_directories[directory - 1]).collect { |feature| feature.name }
|
148
|
+
|
149
|
+
assert { actual_features.flatten.sort == features.raw.flatten.sort }
|
150
|
+
end
|
151
|
+
|
152
|
+
Then /^the files collected from directory "([^"]*)" are as follows:$/ do |directory, files|
|
153
|
+
directory ||= 1
|
154
|
+
|
155
|
+
actual_files = CucumberAnalytics::World.files_in(@parsed_directories[directory - 1]).collect { |file| file.name }
|
156
|
+
|
157
|
+
assert { actual_files.flatten.sort == files.raw.flatten.sort }
|
158
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require 'wrong'
|
5
|
+
include Wrong
|
6
|
+
|
7
|
+
require File.dirname(__FILE__) + '/../../lib/cucumber_analytics'
|
8
|
+
|
9
|
+
|
10
|
+
DEFAULT_FEATURE_FILE_NAME = 'test_feature.feature'
|
11
|
+
DEFAULT_STEP_FILE_NAME = 'test_steps.rb'
|
12
|
+
DEFAULT_FILE_DIRECTORY = "#{File.dirname(__FILE__)}/../temp_files"
|
13
|
+
TEST_FILE_DIRECTORY = "#{File.dirname(__FILE__)}/../test_files"
|
14
|
+
TEST_STEP_FILE_LOCATION = "#{DEFAULT_FILE_DIRECTORY}/#{DEFAULT_STEP_FILE_NAME}"
|
15
|
+
|
16
|
+
|
17
|
+
Before do
|
18
|
+
@default_feature_file_name = DEFAULT_FEATURE_FILE_NAME
|
19
|
+
@default_step_file_name = DEFAULT_STEP_FILE_NAME
|
20
|
+
@test_file_directory = TEST_FILE_DIRECTORY
|
21
|
+
@default_file_directory = DEFAULT_FILE_DIRECTORY
|
22
|
+
@test_step_file_location = TEST_STEP_FILE_LOCATION
|
23
|
+
|
24
|
+
FileUtils.mkdir(@default_file_directory)
|
25
|
+
end
|
26
|
+
|
27
|
+
After do
|
28
|
+
FileUtils.remove_dir(@default_file_directory, true)
|
29
|
+
end
|