testability-driver 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. data/README +1 -0
  2. data/bin/start_app_perf +199 -0
  3. data/bin/tdriver-devtools +3 -0
  4. data/config/sut_parameters.rb +39 -0
  5. data/ext/extconf.rb +67 -0
  6. data/ext/native_extensions.c +70 -0
  7. data/lib/matti.rb +30 -0
  8. data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +223 -0
  9. data/lib/tdriver-devtools/behaviour/old/xml/example/impl.rb_invalid +194 -0
  10. data/lib/tdriver-devtools/behaviour/old/xml/generate_behaviour_xml.rb +95 -0
  11. data/lib/tdriver-devtools/behaviour/old/xml/lib/tdriver_generator.rb +722 -0
  12. data/lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb +321 -0
  13. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.method.template +43 -0
  14. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.module.template +54 -0
  15. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument.template +7 -0
  16. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument_type.template +7 -0
  17. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.exception.template +5 -0
  18. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.line.template +2 -0
  19. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.template +5 -0
  20. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.method.template +23 -0
  21. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.template +14 -0
  22. data/lib/tdriver-devtools/behaviour/old/xml/update +3 -0
  23. data/lib/tdriver-devtools/behaviour/xml/generate.rb +88 -0
  24. data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +1924 -0
  25. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.default.template +1 -0
  26. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.template +3 -0
  27. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument_type.template +4 -0
  28. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.exception.template +4 -0
  29. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.arguments.template +4 -0
  30. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.deprecated.template +3 -0
  31. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.exceptions.template +3 -0
  32. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.info.template +1 -0
  33. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.returns.template +3 -0
  34. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.tables.template +3 -0
  35. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.template +12 -0
  36. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.returns.template +5 -0
  37. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.item.template +1 -0
  38. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.row.template +2 -0
  39. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.template +8 -0
  40. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.template +14 -0
  41. data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +245 -0
  42. data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +964 -0
  43. data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +68 -0
  44. data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +1865 -0
  45. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +1 -0
  46. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +3 -0
  47. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +4 -0
  48. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +4 -0
  49. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +4 -0
  50. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +3 -0
  51. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +3 -0
  52. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +1 -0
  53. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +3 -0
  54. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +3 -0
  55. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +12 -0
  56. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +5 -0
  57. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +1 -0
  58. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +2 -0
  59. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +7 -0
  60. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +14 -0
  61. data/lib/tdriver-devtools/behaviour/xml_generator/update +3 -0
  62. data/lib/tdriver-devtools/doc/behaviour_xml/QtExampleGestureBehaviour.xml +138 -0
  63. data/lib/tdriver-devtools/doc/behaviour_xml/created.rid +1 -0
  64. data/lib/tdriver-devtools/doc/behaviour_xml/tdriver.hash +1 -0
  65. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_hold.feature.xml +9 -0
  66. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_tap.feature.xml +9 -0
  67. data/lib/tdriver-devtools/doc/generate.rb +892 -0
  68. data/lib/tdriver-devtools/doc/update +1 -0
  69. data/lib/tdriver-devtools/doc/xslt/html.rb +7 -0
  70. data/lib/tdriver-devtools/doc/xslt/template.xsl +1861 -0
  71. data/lib/tdriver-devtools/doc/xslt/update +3 -0
  72. data/lib/tdriver-devtools/plugin/placeholder.txt +1 -0
  73. data/lib/tdriver-devtools/tdriver-devtools.rb +404 -0
  74. data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +233 -0
  75. data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +194 -0
  76. data/lib/tdriver-devtools/tests/feature_tests/generate.rb +82 -0
  77. data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +468 -0
  78. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_attribute.template +5 -0
  79. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_method.template +5 -0
  80. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_attribute.template +5 -0
  81. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_method.template +5 -0
  82. data/lib/tdriver-devtools/tests/feature_tests/update +3 -0
  83. data/lib/tdriver.rb +26 -0
  84. data/lib/tdriver/base/behaviour/behaviour.rb +32 -0
  85. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +94 -0
  86. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +262 -0
  87. data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +111 -0
  88. data/lib/tdriver/base/behaviour/factory.rb +380 -0
  89. data/lib/tdriver/base/behaviour/loader.rb +28 -0
  90. data/lib/tdriver/base/command_data/command_data.rb +51 -0
  91. data/lib/tdriver/base/command_data/loader.rb +25 -0
  92. data/lib/tdriver/base/errors.rb +131 -0
  93. data/lib/tdriver/base/loader.rb +38 -0
  94. data/lib/tdriver/base/state_object.rb +270 -0
  95. data/lib/tdriver/base/sut/adapter.rb +28 -0
  96. data/lib/tdriver/base/sut/controller.rb +119 -0
  97. data/lib/tdriver/base/sut/factory.rb +287 -0
  98. data/lib/tdriver/base/sut/generic/behaviours/application.rb +243 -0
  99. data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
  100. data/lib/tdriver/base/sut/generic/behaviours/find.rb +96 -0
  101. data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +346 -0
  102. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1268 -0
  103. data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +182 -0
  104. data/lib/tdriver/base/sut/generic/behaviours/verification.rb +119 -0
  105. data/lib/tdriver/base/sut/generic/commands/application.rb +219 -0
  106. data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +82 -0
  107. data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +58 -0
  108. data/lib/tdriver/base/sut/generic/plugin.rb +96 -0
  109. data/lib/tdriver/base/sut/loader.rb +35 -0
  110. data/lib/tdriver/base/sut/sut.rb +67 -0
  111. data/lib/tdriver/base/test_object/abstract.rb +179 -0
  112. data/lib/tdriver/base/test_object/behaviours/syncronization.rb +94 -0
  113. data/lib/tdriver/base/test_object/behaviours/test_object.rb +787 -0
  114. data/lib/tdriver/base/test_object/factory.rb +618 -0
  115. data/lib/tdriver/base/test_object/identificator.rb +511 -0
  116. data/lib/tdriver/base/test_object/loader.rb +37 -0
  117. data/lib/tdriver/env.rb +21 -0
  118. data/lib/tdriver/loader.rb +36 -0
  119. data/lib/tdriver/matti.rb +35 -0
  120. data/lib/tdriver/report/error_recovery/tdriver_custom_error_recovery.rb +83 -0
  121. data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +158 -0
  122. data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +98 -0
  123. data/lib/tdriver/report/report.rb +47 -0
  124. data/lib/tdriver/report/report_api.rb +207 -0
  125. data/lib/tdriver/report/report_combine.rb +86 -0
  126. data/lib/tdriver/report/report_crash_file_capture.rb +167 -0
  127. data/lib/tdriver/report/report_creator.rb +571 -0
  128. data/lib/tdriver/report/report_cucumber.rb +158 -0
  129. data/lib/tdriver/report/report_cucumber_listener.rb +337 -0
  130. data/lib/tdriver/report/report_cucumber_reporter.rb +335 -0
  131. data/lib/tdriver/report/report_data_presentation.rb +152 -0
  132. data/lib/tdriver/report/report_data_table.rb +64 -0
  133. data/lib/tdriver/report/report_execution_statistics.rb +284 -0
  134. data/lib/tdriver/report/report_file_capture.rb +159 -0
  135. data/lib/tdriver/report/report_grouping.rb +539 -0
  136. data/lib/tdriver/report/report_junit_xml.rb +147 -0
  137. data/lib/tdriver/report/report_rspec.rb +108 -0
  138. data/lib/tdriver/report/report_test_case_run.rb +621 -0
  139. data/lib/tdriver/report/report_test_run.rb +1286 -0
  140. data/lib/tdriver/report/report_test_unit.rb +175 -0
  141. data/lib/tdriver/report/report_writer.rb +1405 -0
  142. data/lib/tdriver/tdriver.rb +158 -0
  143. data/lib/tdriver/util/common.rb +24 -0
  144. data/lib/tdriver/util/common/array.rb +39 -0
  145. data/lib/tdriver/util/common/crc16.rb +100 -0
  146. data/lib/tdriver/util/common/environment.rb +153 -0
  147. data/lib/tdriver/util/common/error.rb +39 -0
  148. data/lib/tdriver/util/common/file.rb +315 -0
  149. data/lib/tdriver/util/common/gem.rb +108 -0
  150. data/lib/tdriver/util/common/kernel.rb +189 -0
  151. data/lib/tdriver/util/common/loader.rb +39 -0
  152. data/lib/tdriver/util/common/retryable.rb +98 -0
  153. data/lib/tdriver/util/common/string.rb +77 -0
  154. data/lib/tdriver/util/dbaccess/dbaccess.rb +188 -0
  155. data/lib/tdriver/util/dbaccess/dbconnection.rb +41 -0
  156. data/lib/tdriver/util/dbaccess/error.rb +35 -0
  157. data/lib/tdriver/util/dbaccess/loader.rb +29 -0
  158. data/lib/tdriver/util/dynamic_attribute_filter.rb +182 -0
  159. data/lib/tdriver/util/hooking.rb +434 -0
  160. data/lib/tdriver/util/loader.rb +65 -0
  161. data/lib/tdriver/util/localisation.rb +24 -0
  162. data/lib/tdriver/util/localisation/error.rb +32 -0
  163. data/lib/tdriver/util/localisation/loader.rb +28 -0
  164. data/lib/tdriver/util/localisation/localisation.rb +479 -0
  165. data/lib/tdriver/util/logger.rb +377 -0
  166. data/lib/tdriver/util/operator_data/error.rb +29 -0
  167. data/lib/tdriver/util/operator_data/loader.rb +26 -0
  168. data/lib/tdriver/util/operator_data/operator_data.rb +93 -0
  169. data/lib/tdriver/util/other/config.rb +221 -0
  170. data/lib/tdriver/util/parameter.rb +24 -0
  171. data/lib/tdriver/util/parameter/error.rb +45 -0
  172. data/lib/tdriver/util/parameter/loader.rb +37 -0
  173. data/lib/tdriver/util/parameter/parameter.rb +285 -0
  174. data/lib/tdriver/util/parameter/parameter_hash.rb +101 -0
  175. data/lib/tdriver/util/parameter/parameter_template.rb +120 -0
  176. data/lib/tdriver/util/parameter/parameter_user_api.rb +84 -0
  177. data/lib/tdriver/util/parameter/parameter_xml.rb +247 -0
  178. data/lib/tdriver/util/plugin/abstract.rb +60 -0
  179. data/lib/tdriver/util/plugin/error.rb +25 -0
  180. data/lib/tdriver/util/plugin/loader.rb +28 -0
  181. data/lib/tdriver/util/plugin/service.rb +200 -0
  182. data/lib/tdriver/util/recorder.rb +292 -0
  183. data/lib/tdriver/util/stats.rb +90 -0
  184. data/lib/tdriver/util/user_data/error.rb +29 -0
  185. data/lib/tdriver/util/user_data/loader.rb +26 -0
  186. data/lib/tdriver/util/user_data/user_data.rb +103 -0
  187. data/lib/tdriver/util/video_rec.rb +264 -0
  188. data/lib/tdriver/util/xml/abstraction.rb +47 -0
  189. data/lib/tdriver/util/xml/builder.rb +54 -0
  190. data/lib/tdriver/util/xml/document.rb +32 -0
  191. data/lib/tdriver/util/xml/element.rb +32 -0
  192. data/lib/tdriver/util/xml/error.rb +46 -0
  193. data/lib/tdriver/util/xml/loader.rb +46 -0
  194. data/lib/tdriver/util/xml/nil_element.rb +89 -0
  195. data/lib/tdriver/util/xml/nodeset.rb +32 -0
  196. data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +140 -0
  197. data/lib/tdriver/util/xml/parsers/loader.rb +22 -0
  198. data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +111 -0
  199. data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +54 -0
  200. data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +58 -0
  201. data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +58 -0
  202. data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +147 -0
  203. data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +42 -0
  204. data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +187 -0
  205. data/lib/tdriver/util/xml/xml.rb +170 -0
  206. data/lib/tdriver/verify/verify.rb +687 -0
  207. data/lib/tdriver/verify/verify.rb_org +630 -0
  208. data/lib/tdriver/version.rb +21 -0
  209. data/xml/behaviours/generic.xml +495 -0
  210. data/xml/defaults/generic.xml +97 -0
  211. data/xml/defaults/sut_generic.xml +36 -0
  212. data/xml/parameters/tdriver_parameters.xml +23 -0
  213. data/xml/templates/generic.xml +227 -0
  214. metadata +327 -0
@@ -0,0 +1,335 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of Testability Driver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+
21
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'report' ) )
22
+ #Report module which contains the Cucumber, Test::Unit and RSpec report formatters
23
+ begin
24
+ module TDriverReport
25
+ #Class for formatting cucumber report
26
+ class CucumberReporter
27
+ include TDriverReportCreator
28
+ #This method initializes new test run
29
+ #
30
+ # === params
31
+ # === returns
32
+ # === raises
33
+ def initialize(step_mother, io, options)
34
+ #super(step_mother, io, options)
35
+ start_run()
36
+ @options = options
37
+ @current_feature_element = nil
38
+ @current_feature = nil
39
+ @tc_status=nil
40
+ @current_feature_group=nil
41
+ end
42
+ def after_features(features)
43
+ end_test_case(@current_feature_element,@tc_status)
44
+ end
45
+ #This method visits the executed cucumber step and updates the results in to TDriver report
46
+ #
47
+ # === params
48
+ # === returns
49
+ # === raises
50
+ def step_name(keyword, step_match, status, source_indent, background)
51
+ if status == :passed
52
+ step_name = step_match.format_args(lambda{|param| "*#{param}*"})
53
+ update_test_case("#{step_name} PASSED")
54
+ @tc_status='passed'
55
+ end
56
+ if status == :failed
57
+ step_name = step_match.format_args(lambda{|param| "*#{param}*"})
58
+ update_test_case("#{step_name} FAILED")
59
+ @tc_status='failed'
60
+ end
61
+ if status == :skipped
62
+ step_name = step_match.format_args(lambda{|param| "*#{param}*"})
63
+ update_test_case("#{step_name} SKIPPED")
64
+ end
65
+ if status == :undefined
66
+ step_name = step_match.format_args(lambda{|param| "*#{param}*"})
67
+ update_test_case("#{step_name} NOT RUN")
68
+ @tc_status='not run'
69
+ end
70
+ end
71
+ #This method visits the exception caused by a failed step
72
+ #and updates the result in to TDriver report
73
+ #
74
+ # === params
75
+ # === returns
76
+ # === raises
77
+ def exception(exception, status)
78
+ if status == :failed
79
+ capture_screen_test_case()
80
+ update_test_case(exception.message)
81
+ update_test_case(exception.backtrace)
82
+ end
83
+ update_test_case('-') if status == :passed
84
+ end
85
+ #This method visits cucumber scenario name and starts a new test case when
86
+ #new scenario is executed
87
+ #and updates the result in to TDriver report
88
+ #
89
+ # === params
90
+ # === returns
91
+ # === raises
92
+ def scenario_name(keyword, name, file_colon_line, source_indent)
93
+ visit_feature_element_name(keyword, name, file_colon_line, source_indent)
94
+ end
95
+ def feature_name(keyword,name)
96
+ @current_feature_group=keyword + " " + name.gsub(/[:]/,' ')
97
+ add_report_group('Features:'+@current_feature_group+'|')
98
+ end
99
+ #This method determines when new test case needs to be started
100
+ #based on the scenario name info if scenario name is different then a new test case
101
+ #is started
102
+ #
103
+ # === params
104
+ # === returns
105
+ # === raises
106
+ def visit_feature_element_name(keyword, name, file_colon_line, source_indent)
107
+ line = %Q("#{name}")
108
+ @current_feature_element=line if @current_feature_element.nil?
109
+ unless line == @current_feature_element
110
+ end_test_case(@current_feature_element,@tc_status)
111
+ @current_feature_element=line
112
+ end
113
+ start_test_case(@current_feature_element)
114
+ add_test_case_group(@current_feature_group)
115
+ @tc_status=nil
116
+ end
117
+ #This method records the cucumber outline table results in to one test case
118
+ #
119
+ # === params
120
+ # === returns
121
+ # === raises
122
+ def before_outline_table(outline_table)
123
+ update_test_case("running outline: ")
124
+ end
125
+ #This method records the cucumber outline table results in to one test case
126
+ #
127
+ # === params
128
+ # === returns
129
+ # === raises
130
+ def after_table_row(table_row)
131
+ if table_row.exception
132
+ @tc_status='failed'
133
+ capture_screen_test_case()
134
+ update_test_case("#{format_table_row(table_row)} FAILED")
135
+ update_test_case(table_row.exception)
136
+ else
137
+ @tc_status='passed' if @tc_status==nil
138
+ update_test_case("#{format_table_row(table_row)} PASSED")
139
+ end
140
+ end
141
+ def format_table_row(row)
142
+ begin
143
+ [row.name, row.line]
144
+ rescue Exception => e
145
+ row
146
+ end
147
+ end
148
+ def tag_name(tag_name)
149
+ end
150
+ def comment_line(comment_line)
151
+ end
152
+ def after_tags(tags)
153
+ end
154
+ def after_feature_element(feature_element)
155
+ end
156
+ def after_background(background)
157
+ end
158
+ def before_examples_array(examples_array)
159
+ end
160
+ def examples_name(keyword, name)
161
+ end
162
+ def py_string(string)
163
+ end
164
+ def print_feature_element_name(keyword, name, file_colon_line, source_indent)
165
+ end
166
+ def before_table_row(table_row)
167
+ return unless @table
168
+ @col_index = 0
169
+ end
170
+ def table_cell_value(value, status)
171
+ return unless @table
172
+ status ||= @status || :passed
173
+ end
174
+ end
175
+ end
176
+
177
+ module MattiReport
178
+ #Class for formatting cucumber report
179
+ class CucumberReporter
180
+ include TDriverReportCreator
181
+ #This method initializes new test run
182
+ #
183
+ # === params
184
+ # === returns
185
+ # === raises
186
+ def initialize(step_mother, io, options)
187
+ file, line = caller.first.split(":")
188
+ $stderr.puts "%s:%s warning: MattiReport deprecated, use TDriverReport instead" % [ file, line]
189
+ #super(step_mother, io, options)
190
+ start_run()
191
+ @options = options
192
+ @current_feature_element = nil
193
+ @current_feature = nil
194
+ @tc_status=nil
195
+ @current_feature_group=nil
196
+ end
197
+ def after_features(features)
198
+ end_test_case(@current_feature_element,@tc_status)
199
+ end
200
+ #This method visits the executed cucumber step and updates the results in to TDriver report
201
+ #
202
+ # === params
203
+ # === returns
204
+ # === raises
205
+ def step_name(keyword, step_match, status, source_indent, background)
206
+ if status == :passed
207
+ step_name = step_match.format_args(lambda{|param| "*#{param}*"})
208
+ update_test_case("#{step_name} PASSED")
209
+ @tc_status='passed'
210
+ end
211
+ if status == :failed
212
+ step_name = step_match.format_args(lambda{|param| "*#{param}*"})
213
+ update_test_case("#{step_name} FAILED")
214
+ @tc_status='failed'
215
+ end
216
+ if status == :skipped
217
+ step_name = step_match.format_args(lambda{|param| "*#{param}*"})
218
+ update_test_case("#{step_name} SKIPPED")
219
+ end
220
+ if status == :undefined
221
+ step_name = step_match.format_args(lambda{|param| "*#{param}*"})
222
+ update_test_case("#{step_name} NOT RUN")
223
+ @tc_status='not run'
224
+ end
225
+ end
226
+ #This method visits the exception caused by a failed step
227
+ #and updates the result in to TDriver report
228
+ #
229
+ # === params
230
+ # === returns
231
+ # === raises
232
+ def exception(exception, status)
233
+ if status == :failed
234
+ capture_screen_test_case()
235
+ update_test_case(exception.message)
236
+ update_test_case(exception.backtrace)
237
+ end
238
+ update_test_case('-') if status == :passed
239
+ end
240
+ #This method visits cucumber scenario name and starts a new test case when
241
+ #new scenario is executed
242
+ #and updates the result in to TDriver report
243
+ #
244
+ # === params
245
+ # === returns
246
+ # === raises
247
+ def scenario_name(keyword, name, file_colon_line, source_indent)
248
+ visit_feature_element_name(keyword, name, file_colon_line, source_indent)
249
+ end
250
+ def feature_name(keyword, name)
251
+ @current_feature_group=keyword + " " + name
252
+ add_report_group('Features:'+@current_feature_group+'|')
253
+ end
254
+ #This method determines when new test case needs to be started
255
+ #based on the scenario name info if scenario name is different then a new test case
256
+ #is started
257
+ #
258
+ # === params
259
+ # === returns
260
+ # === raises
261
+ def visit_feature_element_name(keyword, name, file_colon_line, source_indent)
262
+ line = %Q("#{name}")
263
+ @current_feature_element=line if @current_feature_element.nil?
264
+ unless line == @current_feature_element
265
+ end_test_case(@current_feature_element,@tc_status)
266
+ @current_feature_element=line
267
+ end
268
+ start_test_case(@current_feature_element)
269
+ add_test_case_group(@current_feature_group)
270
+ @tc_status=nil
271
+ end
272
+ #This method records the cucumber outline table results in to one test case
273
+ #
274
+ # === params
275
+ # === returns
276
+ # === raises
277
+ def before_outline_table(outline_table)
278
+ update_test_case("running outline: ")
279
+ end
280
+ #This method records the cucumber outline table results in to one test case
281
+ #
282
+ # === params
283
+ # === returns
284
+ # === raises
285
+ def after_table_row(table_row)
286
+ if table_row.exception
287
+ @tc_status='failed'
288
+ capture_screen_test_case()
289
+ update_test_case("#{format_table_row(table_row)} FAILED")
290
+ update_test_case(table_row.exception)
291
+ else
292
+ @tc_status='passed' if @tc_status==nil
293
+ update_test_case("#{format_table_row(table_row)} PASSED")
294
+ end
295
+ end
296
+ def format_table_row(row)
297
+ begin
298
+ [row.name, row.line]
299
+ rescue Exception => e
300
+ row
301
+ end
302
+ end
303
+ def tag_name(tag_name)
304
+ end
305
+ def comment_line(comment_line)
306
+ end
307
+ def after_tags(tags)
308
+ end
309
+ def after_feature_element(feature_element)
310
+ end
311
+ def after_background(background)
312
+ end
313
+ def before_examples_array(examples_array)
314
+ end
315
+ def examples_name(keyword, name)
316
+ end
317
+ def py_string(string)
318
+ end
319
+ def print_feature_element_name(keyword, name, file_colon_line, source_indent)
320
+ end
321
+ def before_table_row(table_row)
322
+ return unless @table
323
+ @col_index = 0
324
+ end
325
+ def table_cell_value(value, status)
326
+ return unless @table
327
+ status ||= @status || :passed
328
+ end
329
+ end
330
+ end
331
+
332
+
333
+ rescue LoadError
334
+
335
+ end
@@ -0,0 +1,152 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of Testability Driver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+
21
+
22
+ module TDriverReportDataPresentation
23
+ include TDriverReportWriter
24
+
25
+ ## This method will create a .png image with a graph
26
+ ## Arguments
27
+ # data:: Hash: Data to be ploted in the form of {"signal_name" => [ value 1, value 2, .., value n] , ...}
28
+ # filename:: String: filname for the image that will be generated. Should have .png extension
29
+ # title:: String: Title for the graph
30
+ ## Returns
31
+ # String: String with the <img> tag to be inserted into an html file
32
+ ## Exceptions
33
+ # ArgumentError: Thown when data or filname provided are either nil or the wrong types
34
+ def create_graph_image( data, filename, title = nil)
35
+ begin
36
+ require 'gruff'
37
+ rescue Exception => e
38
+ puts "Can't load the Gruff gem. If its missing from your system please run 'gem install gruff' to install it."
39
+ puts e.inspect
40
+ end
41
+ begin
42
+ raise ArgumentError, "ERROR create_graph_image: Data argument is either nil or not a Hash" if ( data.nil? or !data.kind_of? Hash )
43
+ raise ArgumentError, "ERROR create_graph_image: Values of the data Hash need to be arrays of minimum length 2" if ( !data.values[0].kind_of? Array or data.values[0].length < 2 )
44
+ raise ArgumentError, "ERROR create_graph_image: Filename argument is either missing or not a String" if ( filename.nil? or !filename.kind_of? String )
45
+ g = Gruff::Line.new
46
+ g.title = title unless title.nil?
47
+ data.each_key do |signal|
48
+ g.data( signal, data[signal])
49
+ end
50
+ # boring labels for now
51
+ #data[data.keys[0]].length.times do |i|
52
+ # g.labels[i] = (i + 1).to_s
53
+ #end
54
+ g.write(filename)
55
+ rescue ArgumentError => e
56
+ puts e.message
57
+ end
58
+ end
59
+
60
+ ## This method returns an html img tag to an image with a graph of the data provided
61
+ ## Arguments
62
+ # data:: Hash: Data to be ploted in the form of {"signal_name" => [ value 1, value 2, .., value n] , ...}
63
+ # filename:: String: filname for the image that will be generated. Should have .png extension
64
+ # title:: String: Title for the graph
65
+ # width:: String/Integer: desired width in number of pixels for the image. Defaults to "auto"
66
+ ## Returns
67
+ # String: String with the <img> tag to be inserted into an html file
68
+ ## Exceptions
69
+ # ArgumentError: Thown when data is either nil or the wrong types
70
+ def insert_html_graph( data, filename = nil , title = nil, width = nil )
71
+ filename = "graph.png" if filename.nil?
72
+ title = "Application Start Performance" if title.nil?
73
+ create_graph_image(data, filename, title)
74
+ html = "\n<img class='graph' src='#{filename}' style='width:#{ width.nil? ? 'auto' : width.to_s + 'px' }'/>\n"
75
+ end
76
+
77
+ ## This method will create an html table tag with the data provided
78
+ ## Arguments
79
+ # data:: Hash: Data to be ploted in the form of {"signal_name" => [ value 1, value 2, .., value n] , ...}
80
+ # width:: String/Integer: desired width in number of pixels for the table. Defaults to "auto"
81
+ ## Returns
82
+ # String: String with the <table> tag to be inserted into an html file
83
+ ## Exceptions
84
+ #
85
+ def insert_html_table( data, width = nil )
86
+ raise ArgumentError, "Data argument is either nul or not a Hash" if ( data.nil? or data.class.to_s != "Hash" )
87
+ html = "\n<table class='graph' style='width:#{ width.nil? ? 'auto' : width.to_s + 'px' }'>"
88
+ # table headers
89
+ ( data[data.keys[0]].length + 1).times do |i|
90
+ html << ( i.zero? ? "\n<td class='tbl_header'>Signal/Event</td>" : "\n<td class='tbl_header'>#{i.to_s}</td>")
91
+ end
92
+ # table data
93
+ data.each_key do |signal|
94
+ html << "\n<tr>\n<td>#{signal}</td>"
95
+ data[signal].each do |value|
96
+ html << "\n<td class='tbl_body'>#{value.to_s}</td>"
97
+ end
98
+ html << "\n</tr>"
99
+ end
100
+ html << "\n</table>\n"
101
+ end
102
+
103
+ ## This method inserts the graph specific styles
104
+ ## Returns
105
+ # String: String with the <stile> tag to be added to an html page including either the graph or the table provided by this module
106
+ def insert_graph_css()
107
+ css = '
108
+ <style>
109
+ table.graph
110
+ { text-align: center;
111
+ font-family: Verdana;
112
+ font-weight: normal;
113
+ font-size: 11px;
114
+ color: #404040;
115
+ width: auto;
116
+ background-color: #fafafa;
117
+ border: 1px #6699CC solid;
118
+ border-collapse: collapse;
119
+ border-spacing: 0px; }
120
+
121
+ td.tbl_header
122
+ { border-bottom: 2px solid #6699CC;
123
+ border-left: 1px solid #6699CC;
124
+ background-color: #BEC8D1;
125
+ text-align: left;
126
+ text-indent: 5px;
127
+ font-family: Verdana;
128
+ font-weight: bold;
129
+ font-size: 11px;
130
+ color: #404040; }
131
+
132
+ td.tbl_body
133
+ { border-bottom: 1px solid #9CF;
134
+ border-top: 0px;
135
+ border-left: 1px solid #9CF;
136
+ border-right: 0px;
137
+ text-align: left;
138
+ text-indent: 10px;
139
+ font-family: Verdana, sans-serif, Arial;
140
+ font-weight: normal;
141
+ font-size: 11px;
142
+ color: #404040;
143
+ background-color: #fafafa; }
144
+
145
+ img.graph
146
+ {border: 1px solid #9CF;
147
+ width:auto;
148
+ height:auto}
149
+ </style>
150
+ '
151
+ end
152
+ end