cutedriver-driver 2.0.0.20210120164037

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.
Files changed (226) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +16 -0
  3. data/bin/start_app_perf +200 -0
  4. data/bin/tdriver-devtools +3 -0
  5. data/config/sut_parameters.rb +52 -0
  6. data/config/sut_setup.rb +32 -0
  7. data/config/sut_teardown.rb +32 -0
  8. data/config/tdriver_custom_error_recovery.rb +83 -0
  9. data/ext/extconf.rb +70 -0
  10. data/ext/native_extensions.c +315 -0
  11. data/lib/matti.rb +25 -0
  12. data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +120 -0
  13. data/lib/tdriver-devtools/behaviour/old/xml/example/impl.rb_invalid +194 -0
  14. data/lib/tdriver-devtools/behaviour/old/xml/generate_behaviour_xml.rb +95 -0
  15. data/lib/tdriver-devtools/behaviour/old/xml/lib/tdriver_generator.rb +722 -0
  16. data/lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb +321 -0
  17. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.method.template +43 -0
  18. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.module.template +54 -0
  19. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument.template +7 -0
  20. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument_type.template +7 -0
  21. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.exception.template +5 -0
  22. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.line.template +2 -0
  23. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.template +5 -0
  24. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.method.template +23 -0
  25. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.template +14 -0
  26. data/lib/tdriver-devtools/behaviour/old/xml/update +3 -0
  27. data/lib/tdriver-devtools/behaviour/xml/generate.rb +88 -0
  28. data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +1945 -0
  29. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.default.template +1 -0
  30. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.template +3 -0
  31. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument_type.template +4 -0
  32. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.exception.template +4 -0
  33. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.arguments.template +4 -0
  34. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.deprecated.template +3 -0
  35. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.exceptions.template +3 -0
  36. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.info.template +1 -0
  37. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.returns.template +3 -0
  38. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.tables.template +3 -0
  39. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.template +12 -0
  40. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.returns.template +5 -0
  41. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.item.template +1 -0
  42. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.row.template +2 -0
  43. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.template +8 -0
  44. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.template +14 -0
  45. data/lib/tdriver-devtools/doc/behaviour_xml/QtExampleGestureBehaviour.xml +138 -0
  46. data/lib/tdriver-devtools/doc/behaviour_xml/created.rid +1 -0
  47. data/lib/tdriver-devtools/doc/behaviour_xml/tdriver.hash +1 -0
  48. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_hold.feature.xml +9 -0
  49. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_tap.feature.xml +9 -0
  50. data/lib/tdriver-devtools/doc/generate.rb +917 -0
  51. data/lib/tdriver-devtools/doc/update +1 -0
  52. data/lib/tdriver-devtools/doc/xslt/html.rb +7 -0
  53. data/lib/tdriver-devtools/doc/xslt/template.xsl +2170 -0
  54. data/lib/tdriver-devtools/doc/xslt/update +3 -0
  55. data/lib/tdriver-devtools/plugin/placeholder.txt +1 -0
  56. data/lib/tdriver-devtools/tdriver-devtools.rb +404 -0
  57. data/lib/tdriver-devtools/tests/feature_tests/example/behaviour_example.rb +100 -0
  58. data/lib/tdriver-devtools/tests/feature_tests/generate.rb +82 -0
  59. data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +468 -0
  60. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_attribute.template +5 -0
  61. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_method.template +5 -0
  62. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_attribute.template +5 -0
  63. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_method.template +5 -0
  64. data/lib/tdriver-devtools/tests/feature_tests/update +3 -0
  65. data/lib/tdriver.rb +23 -0
  66. data/lib/tdriver/base/behaviour/abstract.rb +29 -0
  67. data/lib/tdriver/base/behaviour/behaviours/object_abstract.rb +107 -0
  68. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +99 -0
  69. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +278 -0
  70. data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +119 -0
  71. data/lib/tdriver/base/behaviour/factory.rb +495 -0
  72. data/lib/tdriver/base/behaviour/loader.rb +46 -0
  73. data/lib/tdriver/base/command_data/command_data.rb +51 -0
  74. data/lib/tdriver/base/command_data/loader.rb +29 -0
  75. data/lib/tdriver/base/controller/abstraction.rb +56 -0
  76. data/lib/tdriver/base/controller/loader.rb +21 -0
  77. data/lib/tdriver/base/errors.rb +134 -0
  78. data/lib/tdriver/base/loader.rb +47 -0
  79. data/lib/tdriver/base/state_object.rb +373 -0
  80. data/lib/tdriver/base/sut/adapter.rb +54 -0
  81. data/lib/tdriver/base/sut/controller.rb +151 -0
  82. data/lib/tdriver/base/sut/factory.rb +339 -0
  83. data/lib/tdriver/base/sut/generic/behaviours/agent.rb +77 -0
  84. data/lib/tdriver/base/sut/generic/behaviours/application.rb +427 -0
  85. data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
  86. data/lib/tdriver/base/sut/generic/behaviours/find.rb +107 -0
  87. data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +337 -0
  88. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1888 -0
  89. data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +210 -0
  90. data/lib/tdriver/base/sut/generic/behaviours/verification.rb +222 -0
  91. data/lib/tdriver/base/sut/generic/commands/agent.rb +43 -0
  92. data/lib/tdriver/base/sut/generic/commands/application.rb +274 -0
  93. data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
  94. data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +94 -0
  95. data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +64 -0
  96. data/lib/tdriver/base/sut/generic/plugin.rb +97 -0
  97. data/lib/tdriver/base/sut/loader.rb +35 -0
  98. data/lib/tdriver/base/sut/sut.rb +98 -0
  99. data/lib/tdriver/base/test_object/abstract.rb +208 -0
  100. data/lib/tdriver/base/test_object/adapter.rb +740 -0
  101. data/lib/tdriver/base/test_object/behaviours/syncronization.rb +144 -0
  102. data/lib/tdriver/base/test_object/behaviours/test_object.rb +1047 -0
  103. data/lib/tdriver/base/test_object/cache.rb +134 -0
  104. data/lib/tdriver/base/test_object/factory.rb +684 -0
  105. data/lib/tdriver/base/test_object/loader.rb +51 -0
  106. data/lib/tdriver/base/test_object/verification.rb +178 -0
  107. data/lib/tdriver/base/test_object/xml/abstraction.rb +63 -0
  108. data/lib/tdriver/base/test_object/xml/adapter.rb +773 -0
  109. data/lib/tdriver/env.rb +21 -0
  110. data/lib/tdriver/loader.rb +57 -0
  111. data/lib/tdriver/matti.rb +35 -0
  112. data/lib/tdriver/report/error_recovery/tdriver_custom_error_recovery.rb +83 -0
  113. data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +168 -0
  114. data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +106 -0
  115. data/lib/tdriver/report/report.rb +61 -0
  116. data/lib/tdriver/report/report_api.rb +348 -0
  117. data/lib/tdriver/report/report_combine.rb +86 -0
  118. data/lib/tdriver/report/report_crash_file_capture.rb +178 -0
  119. data/lib/tdriver/report/report_creator.rb +665 -0
  120. data/lib/tdriver/report/report_cucumber.rb +158 -0
  121. data/lib/tdriver/report/report_cucumber_listener.rb +184 -0
  122. data/lib/tdriver/report/report_cucumber_reporter.rb +181 -0
  123. data/lib/tdriver/report/report_data_presentation.rb +156 -0
  124. data/lib/tdriver/report/report_data_table.rb +64 -0
  125. data/lib/tdriver/report/report_execution_statistics.rb +400 -0
  126. data/lib/tdriver/report/report_file_capture.rb +159 -0
  127. data/lib/tdriver/report/report_graph_generator.rb +59 -0
  128. data/lib/tdriver/report/report_grouping.rb +541 -0
  129. data/lib/tdriver/report/report_javascript.rb +199 -0
  130. data/lib/tdriver/report/report_junit_xml.rb +147 -0
  131. data/lib/tdriver/report/report_rspec.rb +108 -0
  132. data/lib/tdriver/report/report_test_case_run.rb +725 -0
  133. data/lib/tdriver/report/report_test_run.rb +1476 -0
  134. data/lib/tdriver/report/report_test_unit.rb +223 -0
  135. data/lib/tdriver/report/report_writer.rb +1621 -0
  136. data/lib/tdriver/tdriver.rb +209 -0
  137. data/lib/tdriver/util/agent/loader.rb +22 -0
  138. data/lib/tdriver/util/agent/service.rb +107 -0
  139. data/lib/tdriver/util/common/array.rb +39 -0
  140. data/lib/tdriver/util/common/boolean.rb +48 -0
  141. data/lib/tdriver/util/common/crc16.rb +149 -0
  142. data/lib/tdriver/util/common/environment.rb +154 -0
  143. data/lib/tdriver/util/common/error.rb +40 -0
  144. data/lib/tdriver/util/common/exception.rb +53 -0
  145. data/lib/tdriver/util/common/exceptions.rb +12 -0
  146. data/lib/tdriver/util/common/file.rb +328 -0
  147. data/lib/tdriver/util/common/gem.rb +109 -0
  148. data/lib/tdriver/util/common/hash.rb +288 -0
  149. data/lib/tdriver/util/common/kernel.rb +253 -0
  150. data/lib/tdriver/util/common/loader.rb +47 -0
  151. data/lib/tdriver/util/common/numeric.rb +159 -0
  152. data/lib/tdriver/util/common/object.rb +159 -0
  153. data/lib/tdriver/util/common/retryable.rb +179 -0
  154. data/lib/tdriver/util/common/stackable.rb +185 -0
  155. data/lib/tdriver/util/common/string.rb +174 -0
  156. data/lib/tdriver/util/database/access.rb +240 -0
  157. data/lib/tdriver/util/database/connection.rb +44 -0
  158. data/lib/tdriver/util/database/error.rb +34 -0
  159. data/lib/tdriver/util/database/loader.rb +28 -0
  160. data/lib/tdriver/util/filters/attribute_filter.rb +121 -0
  161. data/lib/tdriver/util/filters/loader.rb +29 -0
  162. data/lib/tdriver/util/fixture/loader.rb +22 -0
  163. data/lib/tdriver/util/fixture/service.rb +211 -0
  164. data/lib/tdriver/util/hooking/hooking.rb +477 -0
  165. data/lib/tdriver/util/keymap/keymap.rb +81 -0
  166. data/lib/tdriver/util/loader.rb +80 -0
  167. data/lib/tdriver/util/localisation/error.rb +31 -0
  168. data/lib/tdriver/util/localisation/loader.rb +25 -0
  169. data/lib/tdriver/util/localisation/localisation.rb +762 -0
  170. data/lib/tdriver/util/logger/loader.rb +22 -0
  171. data/lib/tdriver/util/logger/logger.rb +591 -0
  172. data/lib/tdriver/util/operator_data/error.rb +29 -0
  173. data/lib/tdriver/util/operator_data/loader.rb +27 -0
  174. data/lib/tdriver/util/operator_data/operator_data.rb +93 -0
  175. data/lib/tdriver/util/other/config.rb +221 -0
  176. data/lib/tdriver/util/parameter/error.rb +48 -0
  177. data/lib/tdriver/util/parameter/loader.rb +25 -0
  178. data/lib/tdriver/util/parameter/parameter.rb +1161 -0
  179. data/lib/tdriver/util/plugin/abstract.rb +61 -0
  180. data/lib/tdriver/util/plugin/error.rb +0 -0
  181. data/lib/tdriver/util/plugin/loader.rb +28 -0
  182. data/lib/tdriver/util/plugin/service.rb +319 -0
  183. data/lib/tdriver/util/recorder/loader.rb +25 -0
  184. data/lib/tdriver/util/recorder/recorder.rb +72 -0
  185. data/lib/tdriver/util/recorder/scripter.rb +294 -0
  186. data/lib/tdriver/util/statistics/statistics.rb +89 -0
  187. data/lib/tdriver/util/user_data/error.rb +28 -0
  188. data/lib/tdriver/util/user_data/loader.rb +25 -0
  189. data/lib/tdriver/util/user_data/user_data.rb +104 -0
  190. data/lib/tdriver/util/video/camera.rb +67 -0
  191. data/lib/tdriver/util/video/camera_linux.rb +153 -0
  192. data/lib/tdriver/util/video/camera_windows.rb +174 -0
  193. data/lib/tdriver/util/video/loader.rb +31 -0
  194. data/lib/tdriver/util/video/video_utils.rb +139 -0
  195. data/lib/tdriver/util/xml/abstraction.rb +117 -0
  196. data/lib/tdriver/util/xml/attribute.rb +32 -0
  197. data/lib/tdriver/util/xml/builder.rb +53 -0
  198. data/lib/tdriver/util/xml/comment.rb +32 -0
  199. data/lib/tdriver/util/xml/document.rb +32 -0
  200. data/lib/tdriver/util/xml/element.rb +32 -0
  201. data/lib/tdriver/util/xml/error.rb +46 -0
  202. data/lib/tdriver/util/xml/loader.rb +62 -0
  203. data/lib/tdriver/util/xml/nil_node.rb +95 -0
  204. data/lib/tdriver/util/xml/nodeset.rb +32 -0
  205. data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +140 -0
  206. data/lib/tdriver/util/xml/parsers/loader.rb +21 -0
  207. data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +167 -0
  208. data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +66 -0
  209. data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +64 -0
  210. data/lib/tdriver/util/xml/parsers/nokogiri/comment.rb +39 -0
  211. data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +66 -0
  212. data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +39 -0
  213. data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +58 -0
  214. data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +212 -0
  215. data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +237 -0
  216. data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +39 -0
  217. data/lib/tdriver/util/xml/text.rb +32 -0
  218. data/lib/tdriver/util/xml/xml.rb +332 -0
  219. data/lib/tdriver/verify/verify.rb +2398 -0
  220. data/lib/tdriver/version.rb +21 -0
  221. data/xml/behaviours/generic.xml +530 -0
  222. data/xml/defaults/generic.xml +11 -0
  223. data/xml/defaults/sut_generic.xml +8 -0
  224. data/xml/parameters/tdriver_parameters.xml +23 -0
  225. data/xml/templates/generic.xml +292 -0
  226. metadata +324 -0
@@ -0,0 +1 @@
1
+ <default>$ARGUMENT_DEFAULT_VALUE</default>
@@ -0,0 +1,3 @@
1
+
2
+ <argument name="$ARGUMENT_NAME" optional="$ARGUMENT_OPTIONAL" type="$ARGUMENT_TYPE">
3
+ $ARGUMENT_TYPES$ARGUMENT_DEFAULT_VALUE </argument>
@@ -0,0 +1,4 @@
1
+ <type name="$ARGUMENT_TYPE">
2
+ <description>$ARGUMENT_DESCRIPTION</description>
3
+ <example>$ARGUMENT_EXAMPLE</example>
4
+ </type>
@@ -0,0 +1,4 @@
1
+ <exception name="$EXCEPTION_NAME">
2
+ <description>$EXCEPTION_DESCRIPTION</description>
3
+ </exception>
4
+
@@ -0,0 +1,4 @@
1
+
2
+ <arguments implemented="$ARGUMENTS_IMPLEMENTED" optional="$ARGUMENT_OPTIONAL_COUNT">
3
+ $METHOD_ARGUMENTS
4
+ </arguments>
@@ -0,0 +1,3 @@
1
+
2
+ <deprecated version="$DEPRECATED_IN_VERSION_NUMBER" />
3
+
@@ -0,0 +1,3 @@
1
+ <exceptions>
2
+
3
+ $METHOD_EXCEPTIONS </exceptions>
@@ -0,0 +1,3 @@
1
+ <returns>
2
+ $METHOD_RETURNS
3
+ </returns>
@@ -0,0 +1,12 @@
1
+
2
+ <method name="$METHOD_NAME" type="$METHOD_TYPE" nodoc="$NODOC">
3
+
4
+ $METHOD_DEPRECATED
5
+ <description>$METHOD_DESCRIPTION</description>
6
+ $METHOD_ARGUMENTS
7
+ $METHOD_RETURNS
8
+ $METHOD_EXCEPTIONS
9
+ $METHOD_TABLES
10
+ $METHOD_INFO
11
+
12
+ </method>
@@ -0,0 +1,5 @@
1
+
2
+ <type name="$RETURN_VALUE_TYPE">
3
+ <description>$RETURN_VALUE_DESCRIPTION</description>
4
+ <example>$RETURN_VALUE_EXAMPLE</example>
5
+ </type>
@@ -0,0 +1,8 @@
1
+
2
+ <table name="$TABLE_NAME">
3
+ <title>$TABLE_TITLE</title>
4
+ <description>$TABLE_DESCRIPTION</description>
5
+ <header>
6
+ $TABLE_HEADER_ITEMS </header>
7
+ $TABLE_ROWS </table>
8
+
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <behaviours plugin="$REQUIRED_PLUGIN">
3
+
4
+ <behaviour name="$BEHAVIOUR_NAME" object_type="$OBJECT_TYPE" sut_type="$SUT_TYPE" input_type="$INPUT_TYPE" version="$VERSION">
5
+
6
+ <module name="$MODULE_NAME" />
7
+
8
+ <methods>
9
+ $BEHAVIOUR_METHODS
10
+ </methods>
11
+
12
+ </behaviour>
13
+
14
+ </behaviours>
@@ -0,0 +1,138 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <behaviours plugin="*">
3
+
4
+ <behaviour name="QtExampleGestureBehaviour" object_type="*;sut" sut_type="qt" input_type="touch" version="*">
5
+
6
+ <module name="MobyBehaviour::QT::Gesture" />
7
+
8
+ <methods>
9
+
10
+ <method name="flick" type="method">
11
+
12
+ <description>Cause a flick operation on the screen.</description>
13
+
14
+ <arguments>
15
+
16
+ <argument name="direction" optional="false" type="normal">
17
+ <type name="Integer">
18
+ <description>Example argument1</description>
19
+ <example>10</example>
20
+ </type>
21
+ <type name="Hash">
22
+ <description>Example argument 1 type 2</description>
23
+ <example>{ :optional_1 => "value_1", :optional_2 => "value_2" }</example>
24
+ </type>
25
+ </argument>
26
+
27
+ <argument name="button" optional="true" type="normal">
28
+ <type name="String">
29
+ <description>which button to use</description>
30
+ <example>"Hello"</example>
31
+ </type>
32
+ <default>:Left</default>
33
+ </argument>
34
+
35
+ <argument name="optional_params" optional="true" type="normal">
36
+ <type name="String">
37
+ <description>optinal parameters for blaa blaa blaa</description>
38
+ <example>{:a => 1, :b => 2}</example>
39
+ </type>
40
+ <default>{}</default>
41
+ </argument>
42
+
43
+ </arguments>
44
+
45
+ <returns>
46
+
47
+ <type name="String">
48
+ <description>Return value type</description>
49
+ <example>"World"</example>
50
+ </type>
51
+
52
+ </returns>
53
+
54
+ <exceptions>
55
+
56
+ <exception name="RuntimeError">
57
+ <description>example exception</description>
58
+ </exception>
59
+
60
+ <exception name="ArgumentError">
61
+ <description>example exception</description>
62
+ </exception>
63
+
64
+ </exceptions>
65
+
66
+ <tables>
67
+
68
+ <table name="custom1">
69
+ <title>Custom table1</title>
70
+ <header>
71
+ <item>hdr1</item>
72
+ <item>hrd2</item>
73
+ <item>hrd3</item>
74
+ </header>
75
+ <row>
76
+ <item>1.1</item>
77
+ <item>1.2</item>
78
+ <item>1.3</item>
79
+ </row>
80
+ <row>
81
+ <item>2.1</item>
82
+ <item>2.2</item>
83
+ <item>2.3</item>
84
+ </row>
85
+ </table>
86
+
87
+ <table name="custom2">
88
+ <title>Custom table2</title>
89
+ <header>
90
+ <item>id</item>
91
+ <item>value</item>
92
+ </header>
93
+ <row>
94
+ <item>0</item>
95
+ <item>true</item>
96
+ </row>
97
+ <row>
98
+ <item>1</item>
99
+ <item>false</item>
100
+ </row>
101
+ </table>
102
+
103
+ </tables>
104
+
105
+ <info>See method X, table at Y</info>
106
+
107
+ </method>
108
+
109
+ <method name="z;z=" type="accessor">
110
+
111
+ <description>example desc</description>
112
+
113
+ <arguments>
114
+
115
+ </arguments>
116
+
117
+ <returns>
118
+
119
+ <type name="String">
120
+ <description>Return value type</description>
121
+ <example>"World"</example>
122
+ </type>
123
+
124
+ </returns>
125
+
126
+ <tables>
127
+
128
+ </tables>
129
+
130
+ <info></info>
131
+
132
+ </method>
133
+
134
+ </methods>
135
+
136
+ </behaviour>
137
+
138
+ </behaviours>
@@ -0,0 +1 @@
1
+ Wed, 22 Sep 2010 14:03:04 +0300
@@ -0,0 +1 @@
1
+ {"MobyBehaviour::QT::Gesture"=>["flick#method#3;2", "z#accessor#0;0"]}
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0"?>
2
+ <feature>
3
+ <description>MobyBehaviour::QT::Widget#hold</description>
4
+ <description>
5
+ As a test scripter writer
6
+ I want to use hold method to [DO_SOMETHING] in [TARGET_APPLICATION]
7
+ so that I can test the MobyBehaviour::QT::Widget behaviour</description>
8
+ <scenarios><scenario><description>Testing hold method with required argument(s) (Rename this to be more descriptive)</description><step>I launch application [APPLICATION_NAME] as @app NOT RUN</step><example_step>I execute "@app.[SOME_OBJECT].hold()" SKIPPED</example_step><step>[ADD_YOUR_VERIFICATION_HERE] NOT RUN</step></scenario><scenario><description>Testing hold method with optional argument 'button' (Rename this to be more descriptive)</description><step>I launch application [APPLICATION_NAME] as @app NOT RUN</step><example_step>I execute "@app.[SOME_OBJECT].hold(button)" SKIPPED</example_step><step>[ADD_YOUR_VERIFICATION_HERE] NOT RUN</step></scenario><scenario><description>Testing hold method with optional argument 'refresh' (Rename this to be more descriptive)</description><step>I launch application [APPLICATION_NAME] as @app NOT RUN</step><example_step>I execute "@app.[SOME_OBJECT].hold(button, refresh)" SKIPPED</example_step><step>[ADD_YOUR_VERIFICATION_HERE] NOT RUN</step></scenario></scenarios>
9
+ </feature>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0"?>
2
+ <feature>
3
+ <description>MobyBehaviour::QT::Widget#tap</description>
4
+ <description>
5
+ As a test script writer
6
+ I want to use tap method to simulate user tapping or clicking an object,
7
+ so that I can test the MobyBehaviour::QT::Widget behaviour</description>
8
+ <scenarios><scenario><description>Testing tap method without arguments</description><step>I launch application "calculator" PASSED</step><example_step>I execute "@app.Button(:name =&gt; 'oneButton').tap" PASSED</example_step><step>The calculator display says "1" PASSED</step></scenario><scenario><description>Testing tap method with optional argument 'tap_params' (Rename this to be more descriptive)</description><step>I launch application [APPLICATION_NAME] as @app NOT RUN</step><example_step>I execute "@app.[SOME_OBJECT].tap(tap_params)" SKIPPED</example_step><step>[ADD_YOUR_VERIFICATION_HERE] NOT RUN</step></scenario><scenario><description>Testing tap method with optional argument 'interval' (Rename this to be more descriptive)</description><step>I launch application [APPLICATION_NAME] as @app NOT RUN</step><example_step>I execute "@app.[SOME_OBJECT].tap(tap_params, interval)" SKIPPED</example_step><step>[ADD_YOUR_VERIFICATION_HERE] NOT RUN</step></scenario><scenario><description>Testing tap method with optional argument 'button' (Rename this to be more descriptive)</description><step>I launch application [APPLICATION_NAME] as @app NOT RUN</step><example_step>I execute "@app.[SOME_OBJECT].tap(tap_params, interval, button)" SKIPPED</example_step><step>[ADD_YOUR_VERIFICATION_HERE] NOT RUN</step></scenario></scenarios>
9
+ </feature>
@@ -0,0 +1,917 @@
1
+ require 'nokogiri'
2
+
3
+ @feature_tests = []
4
+ @behaviour_hashes = {}
5
+ @behaviours = []
6
+ $features = 0
7
+ $features_nodoc = 0
8
+
9
+ $passed, $failed, $unknown = [ 0, 0, 0 ]
10
+
11
+ $modules_and_methods_tested = {}
12
+
13
+ def process_result_file( content )
14
+
15
+ result = { "__file" => @current_file }
16
+
17
+ # convert linefeeds to whitespace
18
+ #content.gsub!( "\n", ' ' )
19
+
20
+ # convert double whitespaces to one whitespace
21
+ content.gsub!( ' ', ' ' )
22
+
23
+ doc = Nokogiri::XML::parse( content )
24
+
25
+ # parse each element
26
+ doc.root.children.each{ | child |
27
+
28
+ if child.kind_of?( Nokogiri::XML::Element )
29
+
30
+ case child.name.to_s
31
+
32
+ when /^description$/i
33
+
34
+ # collect description, remove empty lines, strip leading and trailing whitespaces, split lines
35
+ result[ child.name.to_s ] = ( result[ child.name.to_s ] || [] ) + child.inner_text.split("\n").collect{ | value | value.empty? ? nil : value.strip }.compact
36
+
37
+ when /^scenarios$/i
38
+
39
+ scenarios = []
40
+
41
+ # iterate through each scenario
42
+ child.children.each{ | scenario |
43
+
44
+ scenario_data = {}
45
+
46
+ scenario.children.each{ | data |
47
+
48
+ if child.kind_of?( Nokogiri::XML::Element )
49
+
50
+ scenario_data[ data.name.to_s ] = ( scenario_data[ data.name.to_s ] || [] ) + data.inner_text.split("\n").collect{ | value | value.empty? ? nil : value.strip }.compact
51
+
52
+ end
53
+
54
+ }
55
+
56
+ scenarios << scenario_data
57
+
58
+ }
59
+
60
+ result[ child.name.to_s ] = scenarios
61
+
62
+ when /^text$/i
63
+
64
+ # skip any element inner texts
65
+
66
+ else
67
+
68
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
69
+
70
+ end
71
+
72
+ end
73
+
74
+ }
75
+
76
+ result
77
+
78
+ end
79
+
80
+ def process_behaviour_hash_file( content )
81
+
82
+ eval( content )
83
+
84
+ end
85
+
86
+ def process_behaviour_file( content )
87
+
88
+ # TODO: recursive method to parse documentation?
89
+
90
+ begin
91
+
92
+ doc = Nokogiri::XML::parse( content )
93
+
94
+ behaviour_config = Hash[ doc.root.attributes.collect{ | attribute | [ attribute.first, attribute.last.value ] } ] # ] = attribute.last.value.split(";") }
95
+
96
+ rescue Exception => exception
97
+
98
+ abort("Error while parsing behaviour:\n#{ content }")
99
+
100
+ end
101
+
102
+ result = { "behaviours" => [], "__config" => behaviour_config }
103
+
104
+ # parse each element
105
+ doc.root.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
106
+
107
+ case child.name.to_s
108
+
109
+ when /^behaviour$/i
110
+
111
+ # new behaviour hash
112
+ behaviour = {}
113
+
114
+ # get behaviour element attributes, e.g. behaviour name, input_type, sut_type etc
115
+ child.attributes.each{ | attribute |
116
+
117
+ behaviour[ attribute.first ] = attribute.last.value.split(";")
118
+
119
+ }
120
+
121
+ # retrieve module & method definitions
122
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
123
+
124
+ case child.name.to_s
125
+
126
+ when /^methods$/i
127
+
128
+ methods = []
129
+
130
+ # get method definitions
131
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
132
+
133
+ method = {}
134
+
135
+ # get behaviour element attributes, e.g. behaviour name, input_type, sut_type etc
136
+ child.attributes.each{ | attribute |
137
+ method[ attribute.first ] = attribute.last.value.split(";")
138
+ }
139
+
140
+ # retrieve method details
141
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
142
+
143
+ case child.name.to_s
144
+
145
+ when /^deprecated$/i
146
+
147
+ method[ "deprecated" ] = child.attribute("version").value.to_s
148
+
149
+ when /^description$/i, /^info$/i
150
+
151
+ # store description, info
152
+ method[ child.name.to_s ] = child.inner_text
153
+
154
+ when /^arguments$/i
155
+
156
+ method[ "arguments_data" ] = {}
157
+
158
+ arguments = []
159
+
160
+ child.attributes.each{ | attribute |
161
+
162
+ method[ "arguments_data" ][ attribute.first ] = attribute.last.value
163
+
164
+ }
165
+
166
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
167
+
168
+ argument = { "types" => [] }
169
+
170
+ # get behaviour element attributes, e.g. behaviour name, input_type, sut_type etc
171
+ child.attributes.each{ | attribute |
172
+
173
+ argument[ attribute.first ] = attribute.last.value.split(";")
174
+
175
+ }
176
+
177
+ # get each argument details, e.g. type(s), default value etc
178
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
179
+
180
+ case child.name.to_s
181
+
182
+ when /^default$/
183
+
184
+ argument[ child.name.to_s ] = child.inner_text.to_s
185
+
186
+ when /^type$/
187
+
188
+ argument[ "types" ] << Hash[ child.attribute("name").value, Hash[ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.collect{ | child | [ child.name, child.inner_text ] } ] ]
189
+
190
+ else
191
+
192
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
193
+
194
+ end
195
+
196
+ }
197
+
198
+ arguments << argument
199
+
200
+ }
201
+
202
+ method[ "arguments" ] = arguments
203
+
204
+ when /^returns$/i
205
+
206
+ returns = []
207
+
208
+ # get each argument details, e.g. type(s), default value etc
209
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
210
+
211
+ case child.name.to_s
212
+
213
+ when /^type$/
214
+
215
+ returns << Hash[ child.attribute("name").value, Hash[ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.collect{ | child | [ child.name, child.inner_text ] } ] ]
216
+
217
+ else
218
+
219
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
220
+
221
+ end
222
+
223
+ }
224
+
225
+ method[ "returns" ] = returns
226
+
227
+ when /^exceptions$/i
228
+
229
+ exceptions = []
230
+
231
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
232
+
233
+ case child.name.to_s
234
+
235
+ when /^exception$/
236
+
237
+ exceptions << Hash[ child.attribute("name").value, Hash[ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.collect{ | child | [ child.name, child.inner_text ] } ] ]
238
+
239
+ else
240
+
241
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
242
+
243
+ end
244
+
245
+ }
246
+
247
+ method[ "exceptions" ] = exceptions
248
+
249
+ when /^tables$/i
250
+
251
+ tables = []
252
+
253
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
254
+
255
+ case child.name.to_s
256
+
257
+ when /^table$/i
258
+
259
+ table = { "name" => child.attribute("name").value, "title" => "", "header" => [], "row" => [] }
260
+
261
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
262
+
263
+ case child.name.to_s
264
+
265
+ when /^title$/i
266
+
267
+ table[ "title" ] = child.inner_text
268
+
269
+ when /^description$/i
270
+
271
+ table[ "description" ] = child.inner_text
272
+
273
+ when /^header$/i, /^row$/i #, /^title$/, /^description$/
274
+
275
+ table[ child.name.to_s ] << child.children.select{ | node |
276
+ node.kind_of?( Nokogiri::XML::Element ) }.collect{ | child |
277
+ child.inner_text
278
+ }
279
+
280
+ else
281
+
282
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
283
+
284
+ end
285
+
286
+ }
287
+
288
+ tables << table
289
+
290
+ else
291
+
292
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
293
+
294
+ end
295
+
296
+ }
297
+
298
+ method[ "tables" ] = tables
299
+
300
+ # if element under methods node is unknown...
301
+ else
302
+
303
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
304
+
305
+ end
306
+
307
+ }
308
+
309
+ methods << method
310
+
311
+ }
312
+
313
+ behaviour[ "methods" ] = methods
314
+
315
+
316
+ when /^module$/i
317
+
318
+ behaviour[ child.name.to_s ] = child.attribute("name").value.split(";")
319
+
320
+ else
321
+
322
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
323
+
324
+ end
325
+
326
+ }
327
+
328
+ result[ "behaviours" ] << behaviour
329
+
330
+ when /^text$/i
331
+
332
+ # skip any element inner texts
333
+
334
+ else
335
+
336
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
337
+
338
+ end
339
+
340
+
341
+ }
342
+
343
+ result
344
+
345
+ end
346
+
347
+ def read_test_result_files( folder )
348
+
349
+ Dir.glob( File.join( folder, '*.xml' ) ).each{ | file |
350
+
351
+ @current_file = file
352
+
353
+
354
+
355
+ @feature_tests << process_result_file( open( file, 'r' ).read )
356
+
357
+ }
358
+
359
+ puts "\nTest result files: #{ @feature_tests.count }"
360
+
361
+ end
362
+
363
+ def read_behaviour_xml_files( folder )
364
+
365
+ if File.directory?( folder )
366
+
367
+ files = Dir.glob( File.join( folder, '*.xml' ) )
368
+
369
+ else
370
+
371
+ files = [ folder ]
372
+ end
373
+
374
+ files.each{ | file |
375
+
376
+ @current_file = file
377
+
378
+ @behaviours << { :filename => file, :behaviours => process_behaviour_file( open( file, 'r' ).read ) }
379
+
380
+ }
381
+
382
+ puts "Behaviour XML files: #{ @behaviours.count }"
383
+
384
+ end
385
+
386
+ def read_behaviour_hash_files( folder )
387
+
388
+ Dir.glob( File.join( folder, '*.hash' ) ).each{ | file |
389
+
390
+ @current_file = file
391
+
392
+ content = open( file, 'r' ).read
393
+
394
+ # merge to results table
395
+ process_behaviour_hash_file( open( file, 'r' ).read ).each_pair{ | key, value |
396
+
397
+ @behaviour_hashes[ key.to_s ] = ( @behaviour_hashes[ key.to_s ] || [] ) | value
398
+
399
+ }
400
+
401
+ }
402
+
403
+ abort "No behaviour XML files found from folder '#{ folder }'" if @behaviour_hashes.empty?
404
+
405
+ end
406
+
407
+ =begin
408
+ def collect_all_features
409
+
410
+ @behaviour_hashes.collect{ | module_name, methods |
411
+
412
+ methods.collect{ | method |
413
+
414
+ "%s#%s" % [ module_name, method ]
415
+
416
+ }
417
+
418
+ }.flatten
419
+
420
+ end
421
+ =end
422
+
423
+ def collect_documented_features
424
+
425
+ behaviours = {}
426
+
427
+ @behaviours.each{ | behaviour |
428
+
429
+ file_name = behaviour[ :filename ]
430
+
431
+ behaviour_config = behaviour[:behaviours]["__config"] || {}
432
+
433
+ behaviour[:behaviours]["behaviours"].each{ | behaviour |
434
+
435
+ config = Hash[ behaviour.select{ | key, value | key != "methods" } ]
436
+
437
+ # get module name
438
+ module_name = behaviour["module"].first
439
+
440
+ # list methods
441
+ behaviour["methods"].each{ | method |
442
+
443
+ method["name"].each{ | method_name |
444
+
445
+ behaviours[ "%s#%s" % [ module_name, method_name ] ] = method.merge( "__file" => file_name, "__behaviour" => config.merge( behaviour_config ) )
446
+
447
+ }
448
+
449
+ }
450
+
451
+ }
452
+
453
+ }.flatten
454
+
455
+ behaviours
456
+
457
+ end
458
+
459
+ def collect_feature_tests
460
+
461
+ result = {}
462
+
463
+ @feature_tests.collect{ | feature |
464
+
465
+ result[ ( feature["description"] || ["no feature test description"] ).first ] =
466
+
467
+ ( feature["scenarios"] || [] ).collect{ | scenario |
468
+
469
+ # collect step status
470
+ step_results = ( scenario[ "step" ] || [] ).collect{ | step |
471
+
472
+ # do not process commented lines
473
+ next if /^#/.match( step )
474
+
475
+ #p scenario
476
+
477
+ if /^.*\s{1}(\w+)$/.match( step )
478
+
479
+ $1
480
+
481
+ else
482
+
483
+ "unknown"
484
+
485
+ end
486
+
487
+ #( /^.*\s{1}(\w+)$/.match( step ).captures || [] ).first
488
+
489
+ }
490
+
491
+ # remove nils (skipped lines comment lines)
492
+ step_results.compact! unless step_results.nil?
493
+
494
+ unless scenario["example_step"].nil?
495
+
496
+ scenario["example_step"] = [ scenario["example_step"].join( "\n" ) ]
497
+
498
+ end
499
+
500
+ ( scenario["example_step"] || [] ).collect{ | example |
501
+
502
+ begin
503
+
504
+ code = /"([^\"]*)"\s/m.match( example ).captures.first
505
+ #code = /\"(.*)\"\s/m.match( example ).captures.first
506
+
507
+ status = /^.*\s{1}(\w+)$/m.match( example ).captures.to_a
508
+
509
+ if status.first.to_s.downcase == 'passed'
510
+
511
+ if ( step_results - status ).count > 0
512
+ status_literal = "failed"
513
+ $failed += 1
514
+ else
515
+ status_literal = "passed"
516
+ $passed += 1
517
+ end
518
+
519
+ else
520
+
521
+ if status.first.to_s.empty?
522
+ status_literal = "unknown"
523
+ $unknown += 1
524
+ else
525
+ status_literal = "failed"
526
+ $failed += 1
527
+ end
528
+
529
+ end
530
+
531
+ rescue Exception => exception
532
+
533
+ warn("Ambiguous 'example_step': %s (%s: %s)" % [ example.inspect, exception.class, exception.message ])
534
+
535
+ code = "Error while extracting the code from test"
536
+ status_literal = "unknown"
537
+ $unknown += 1
538
+
539
+ end
540
+
541
+ [
542
+ "example" => code,
543
+ "status" => status_literal,
544
+ "description" => ( scenario["description"] || "" )
545
+ ]
546
+
547
+ }.flatten
548
+
549
+ }.flatten
550
+
551
+ }.flatten
552
+
553
+ result
554
+
555
+ end
556
+
557
+ def generate_document_xml
558
+
559
+ doc = Nokogiri::XML::Builder.new{ | xml |
560
+
561
+ xml.documentation{
562
+
563
+ # TODO: behaviour.hash should have feature type (method/attribute) mentioned
564
+ # TODO: behaviour.hash should have number of arguments incl. optional + blocks
565
+
566
+
567
+ # p @documented_features
568
+
569
+ @documented_features.sort.each{ | feature_name, feature_documentation |
570
+
571
+ feature_documentation.default = ""
572
+
573
+ module_name, method_name = feature_name.split("#")
574
+
575
+ feature_type = feature_documentation[ "type" ].first
576
+
577
+ arguments_count = feature_documentation[ "arguments_data" ][ "implemented" ]
578
+ optional_arguments_count = feature_documentation[ "arguments_data" ][ "optional" ]
579
+
580
+ }
581
+
582
+ #exit
583
+
584
+ @documented_features.sort.each{ | feature, feature_documentation |
585
+
586
+ #module_name, method_name, feature_type, feature_parameters = feature.split("#")
587
+
588
+ #arguments_count, optional_arguments_count = feature_parameters.split(";")
589
+
590
+
591
+
592
+ module_name, method_name = feature.split("#")
593
+
594
+ feature_type = feature_documentation[ "type" ].first
595
+
596
+ arguments_count = feature_documentation[ "arguments_data" ][ "implemented" ]
597
+ optional_arguments_count = feature_documentation[ "arguments_data" ][ "optional" ]
598
+
599
+
600
+ feature = "%s#%s" % [ module_name, method_name ]
601
+
602
+ # make name for feature
603
+ feature_name = case feature_type
604
+
605
+ when "accessor"
606
+ [ method_name, method_name + "=" ]
607
+
608
+ when "writer"
609
+ [ method_name + "=" ]
610
+
611
+ when "reader", "method"
612
+ [ method_name ]
613
+
614
+ else
615
+
616
+ warn("Unknown feature type %s for %s" % [ feature_type, feature ] )
617
+
618
+ [ method_name ]
619
+
620
+ end
621
+
622
+ # get document
623
+
624
+ #documented = @documented_features.keys.include?( feature )
625
+
626
+ #feature_documentation = {}
627
+ #feature_documentation.default = ""
628
+
629
+ # if documented
630
+
631
+ # feature_documentation.merge!( @documented_features[ feature.to_s ] )
632
+
633
+ # end
634
+
635
+ # next if feature_documentation.empty?
636
+
637
+ $features += 1
638
+
639
+ if feature_documentation["nodoc"][0].to_s.downcase == "true"
640
+ $features_nodoc += 1
641
+ next
642
+ end
643
+
644
+ # <feature type="accessor" name="z;z=" types="qt" versions="*" input_types="touch" object_types="*;sut" requires_plugin="x">
645
+ xml.feature(
646
+ :type => feature_type,
647
+ :name => feature_name.join(";"),
648
+ :required_plugin => feature_documentation[ "__behaviour" ][ "plugin" ],
649
+ :sut_type => feature_documentation["__behaviour"][ "sut_type" ].join(";"),
650
+ :sut_version => feature_documentation["__behaviour"][ "version" ].join(";"),
651
+ :input_type => feature_documentation["__behaviour"][ "input_type" ].join(";"),
652
+ :object_type => feature_documentation["__behaviour"][ "object_type" ].join(";")
653
+ ){
654
+
655
+ # <behaviour name="QtGestureBehaviour" module="MobyBehaviour::QT::GestureBehaviour" />
656
+ xml.behaviour(
657
+ :name => feature_documentation[ "__behaviour" ][ "name" ],
658
+ :module => module_name
659
+ )
660
+
661
+ if feature_documentation.has_key?( "deprecated" )
662
+
663
+ xml.deprecated( :version => feature_documentation[ "deprecated" ] )
664
+
665
+ end
666
+
667
+ # <description>example</description>
668
+ xml.description( feature_documentation[ "description" ] )
669
+
670
+ # <info>example</info>
671
+ xml.info( feature_documentation[ "info" ] )
672
+
673
+ feature_documentation[ "arguments" ] = [] if feature_documentation[ "arguments" ].kind_of?( String )
674
+
675
+ # <arguments count="1" optional="0" described="1" block="true">
676
+ xml.arguments(
677
+ :count => arguments_count,
678
+ :optional => optional_arguments_count,
679
+ :described => feature_documentation[ "arguments" ].count,
680
+ :block => feature_documentation[ "arguments" ].select{ | arg | ( arg[ "type" ] || [] ).first == "block" }.count > 0
681
+
682
+ ){
683
+
684
+ ( feature_documentation[ "arguments" ] || [] ).each do | argument |
685
+
686
+ # <argument name="value" optional="false" default="11">
687
+ xml.argument(
688
+ :name => argument[ "name" ].first,
689
+ :optional => argument[ "optional" ].first,
690
+ :default => ( argument[ "default" ] || [] ).first,
691
+ :type => argument[ "type" ].first
692
+
693
+ ){
694
+
695
+ # iterate each argument
696
+ ( argument[ "types" ] || [{}] ).each{ | type |
697
+
698
+ type.each_pair do | argument_type, value |
699
+
700
+ # <type name="Integer">
701
+ xml.type!( :name => argument_type ){
702
+
703
+ # <description>Example argument</description>
704
+ xml.description( value[ "description" ] )
705
+
706
+ # <example>12</example>
707
+ xml.example( value[ "example" ] )
708
+
709
+ } # </type>
710
+
711
+ end # type.each_pair
712
+
713
+ } # arguments_types.each
714
+
715
+ } # </argument>
716
+
717
+ end
718
+
719
+ } # </arguments>
720
+
721
+ # <returns>
722
+ xml.returns( :described => feature_documentation[ "returns" ].size ){
723
+
724
+ ( feature_documentation[ "returns" ] || [{}] ).each do | return_value |
725
+
726
+ # each return value type
727
+ return_value.each_pair do | variable_type, value |
728
+
729
+ # <type name="Integer">
730
+ xml.type_( :name => variable_type ){
731
+
732
+ # <description>Example return value</description>
733
+ xml.description( value[ "description" ] || "" )
734
+
735
+ # <example>12</example>
736
+ xml.example( value[ "example" ] || "" )
737
+
738
+ } # </type>
739
+
740
+ end # types.each
741
+
742
+ end # returns.each
743
+
744
+ } # </returns>
745
+
746
+ # <exceptions>
747
+ xml.exceptions( :described => feature_documentation[ "exceptions" ].size ){
748
+
749
+ ( feature_documentation[ "exceptions" ] || [{}] ).each do | exception |
750
+
751
+ # each exception type
752
+ exception.each_pair do | exception_type, value |
753
+
754
+ # <type name="Integer">
755
+ xml.type_( :name => exception_type ){
756
+
757
+ # <description>Example exception</description>
758
+ xml.description( value[ "description" ] )
759
+
760
+ } # </type>
761
+
762
+ end
763
+
764
+ end
765
+
766
+ } # </exceptions>
767
+
768
+ # <tables>
769
+ xml.tables{
770
+
771
+ ( feature_documentation[ "tables" ] || [{}] ).each do | table |
772
+
773
+ xml.table( :name => table[ "name" ] ){
774
+
775
+ xml.title( table[ "title" ].to_s )
776
+ xml.description( table[ "description" ].to_s )
777
+
778
+ xml.header{
779
+ ( table[ "header" ] || [[]] ).first.each{ | item |
780
+ xml.item( item )
781
+ }
782
+ }
783
+
784
+ ( table[ "row" ] || [] ).each{ | row |
785
+
786
+ xml.row{
787
+ row.each{ | item |
788
+ xml.item( item )
789
+ }
790
+ }
791
+ }
792
+
793
+ }
794
+
795
+ end
796
+
797
+ } # </tables>
798
+
799
+ # collect feature tests for method (1), attr_reader (1), attr_writer (1) and attr_accessor (2)
800
+ names = feature_name.collect{ | name |
801
+
802
+
803
+ feature.split("#").first + "#" + name
804
+
805
+ }
806
+
807
+ tests = names.collect{ | feature_test |
808
+
809
+ { feature_test => @executed_tests[ feature_test ] || {} }
810
+
811
+ }.flatten
812
+
813
+ #p tests
814
+
815
+ # <tests count="1" passed="0" skipped="0" failed="0">
816
+ xml.tests(
817
+ :count => tests.count,
818
+ :passed => tests.select{ | scenario | scenario[ "status" ] == "passed" }.count,
819
+ :skipped => tests.select{ | scenario | scenario[ "status" ] == "skipped" }.count,
820
+ :failed => tests.select{ | scenario | scenario[ "status" ] == "failed" }.count
821
+ ){
822
+
823
+ tests.each do | scenario |
824
+
825
+ scenario.each_pair do | scenario_name, scenarios |
826
+
827
+ scenarios.each do | scenario_value |
828
+
829
+ # <scenario type="reader" status="passed">
830
+ xml.scenario(
831
+
832
+ :type => ( feature_type == "accessor" ? ( ( scenario_name[-1] == ?= ) ? "writer" : "reader" ) : feature_type ),
833
+ :status => scenario_value[ "status" ]
834
+
835
+ ){
836
+
837
+ # <description>Example scenario</description>
838
+ xml.description( scenario_value[ "description" ] )
839
+
840
+ # <example>code</example>
841
+ xml.example( scenario_value[ "example" ] )
842
+
843
+ } # </scenario>
844
+
845
+ end
846
+
847
+ end
848
+
849
+ end
850
+
851
+ } # </tests>
852
+
853
+ }
854
+
855
+ }
856
+
857
+ }
858
+ }
859
+
860
+ doc.to_xml.to_s.gsub("<?xml version=\"1.0\"?>") do | head |
861
+ result = head
862
+ result << "\n"
863
+ result << "<?xml-stylesheet type=\"text/xsl\" href=\"template.xsl\"?>"
864
+ end
865
+
866
+ end
867
+
868
+ if ARGV.count < 2
869
+
870
+ abort "\nUsage: #{ File.basename( $0 ) } test_results_folder behaviour_xml_folder [ output_filename ]\n\n"
871
+
872
+ end
873
+
874
+ feature_tests_folder = File.expand_path( $tests || ARGV[ 0 ] || '.' )
875
+ behaviour_xml_folder = File.expand_path( $source || ARGV[ 1 ] || 'behaviour_xml/' )
876
+ output_filename = File.expand_path( $destination || ARGV[2] || 'document.xml' )
877
+
878
+ read_test_result_files( feature_tests_folder) # ok
879
+ read_behaviour_xml_files( behaviour_xml_folder ) # ok
880
+
881
+ #read_behaviour_hash_files( behaviour_xml_folder ) # ok
882
+
883
+ #puts "all executed feature tests:"
884
+ @executed_tests = collect_feature_tests
885
+
886
+ #puts ""
887
+ #puts "all available features:"
888
+ #@all_features = collect_all_features
889
+
890
+ #puts ""
891
+ #puts "all documented features:"
892
+ @documented_features = collect_documented_features
893
+
894
+ accessors = []
895
+
896
+ puts "\nTotal number of tests: #{ $passed + $failed + $unknown }\n"
897
+ puts "Tests with passed status: #{ $passed }"
898
+ puts "Tests with failed status: #{ $failed }"
899
+ puts "Tests with unknown result: #{ $unknown }"
900
+
901
+
902
+ begin
903
+
904
+ open( output_filename, 'w'){ | file | file << generate_document_xml }
905
+
906
+ puts "\nTotal number of features: #{ $features } (#{ $features_nodoc } with nodoc tag)"
907
+
908
+ puts "\nDocumentation XML saved succesfully to #{ output_filename }"
909
+
910
+ rescue Exception => e
911
+
912
+ puts "\nDocumentation XML saved unsuccesfully due to '#{ e.message }' (#{ e.class })"
913
+
914
+ end
915
+
916
+ puts ""
917
+