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 @@
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>
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">
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,7 @@
1
+
2
+ <table name="$TABLE_NAME">
3
+ <title>$TABLE_TITLE</title>
4
+ <header>
5
+ $TABLE_HEADER_ITEMS </header>
6
+ $TABLE_ROWS </table>
7
+
@@ -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,3 @@
1
+ #!/usr/bin/env sh
2
+ rm -rf behaviour_xml
3
+ ruby generate.rb tdriver example/flick-example.rb
@@ -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,892 @@
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
+ doc = Nokogiri::XML::parse( content )
91
+
92
+ behaviour_config = Hash[ doc.root.attributes.collect{ | attribute | [ attribute.first, attribute.last.value ] } ] # ] = attribute.last.value.split(";") }
93
+
94
+ result = { "behaviours" => [], "__config" => behaviour_config }
95
+
96
+ # parse each element
97
+ doc.root.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
98
+
99
+ case child.name.to_s
100
+
101
+ when /^behaviour$/i
102
+
103
+ # new behaviour hash
104
+ behaviour = {}
105
+
106
+ # get behaviour element attributes, e.g. behaviour name, input_type, sut_type etc
107
+ child.attributes.each{ | attribute |
108
+
109
+ behaviour[ attribute.first ] = attribute.last.value.split(";")
110
+
111
+ }
112
+
113
+ # retrieve module & method definitions
114
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
115
+
116
+ case child.name.to_s
117
+
118
+ when /^methods$/i
119
+
120
+ methods = []
121
+
122
+ # get method definitions
123
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
124
+
125
+ method = {}
126
+
127
+ # get behaviour element attributes, e.g. behaviour name, input_type, sut_type etc
128
+ child.attributes.each{ | attribute |
129
+ method[ attribute.first ] = attribute.last.value.split(";")
130
+ }
131
+
132
+ # retrieve method details
133
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
134
+
135
+ case child.name.to_s
136
+
137
+ when /^deprecated$/i
138
+
139
+ method[ "deprecated" ] = child.attribute("version").value.to_s
140
+
141
+ when /^description$/i, /^info$/i
142
+
143
+ # store description, info
144
+ method[ child.name.to_s ] = child.inner_text
145
+
146
+ when /^arguments$/i
147
+
148
+ method[ "arguments_data" ] = {}
149
+
150
+ arguments = []
151
+
152
+ child.attributes.each{ | attribute |
153
+
154
+ method[ "arguments_data" ][ attribute.first ] = attribute.last.value
155
+
156
+ }
157
+
158
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
159
+
160
+ argument = { "types" => [] }
161
+
162
+ # get behaviour element attributes, e.g. behaviour name, input_type, sut_type etc
163
+ child.attributes.each{ | attribute |
164
+
165
+ argument[ attribute.first ] = attribute.last.value.split(";")
166
+
167
+ }
168
+
169
+ # get each argument details, e.g. type(s), default value etc
170
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
171
+
172
+ case child.name.to_s
173
+
174
+ when /^default$/
175
+
176
+ argument[ child.name.to_s ] = child.inner_text.to_s
177
+
178
+ when /^type$/
179
+
180
+ 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 ] } ] ]
181
+
182
+ else
183
+
184
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
185
+
186
+ end
187
+
188
+ }
189
+
190
+ arguments << argument
191
+
192
+ }
193
+
194
+ method[ "arguments" ] = arguments
195
+
196
+ when /^returns$/i
197
+
198
+ returns = []
199
+
200
+ # get each argument details, e.g. type(s), default value etc
201
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
202
+
203
+ case child.name.to_s
204
+
205
+ when /^type$/
206
+
207
+ returns << Hash[ child.attribute("name").value, Hash[ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.collect{ | child | [ child.name, child.inner_text ] } ] ]
208
+
209
+ else
210
+
211
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
212
+
213
+ end
214
+
215
+ }
216
+
217
+ method[ "returns" ] = returns
218
+
219
+ when /^exceptions$/i
220
+
221
+ exceptions = []
222
+
223
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
224
+
225
+ case child.name.to_s
226
+
227
+ when /^exception$/
228
+
229
+ exceptions << Hash[ child.attribute("name").value, Hash[ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.collect{ | child | [ child.name, child.inner_text ] } ] ]
230
+
231
+ else
232
+
233
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
234
+
235
+ end
236
+
237
+ }
238
+
239
+ method[ "exceptions" ] = exceptions
240
+
241
+ when /^tables$/i
242
+
243
+ tables = []
244
+
245
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
246
+
247
+ case child.name.to_s
248
+
249
+ when /^table$/i
250
+
251
+ table = { "name" => child.attribute("name").value, "title" => "", "header" => [], "row" => [] }
252
+
253
+ child.children.select{ | node | node.kind_of?( Nokogiri::XML::Element ) }.each{ | child |
254
+
255
+ case child.name.to_s
256
+
257
+ when /^title$/i
258
+
259
+ table[ "title" ] = child.inner_text
260
+
261
+ when /^description$/i
262
+
263
+ table[ "description" ] = child.inner_text
264
+
265
+ when /^header$/i, /^row$/i #, /^title$/, /^description$/
266
+
267
+ table[ child.name.to_s ] << child.children.select{ | node |
268
+ node.kind_of?( Nokogiri::XML::Element ) }.collect{ | child |
269
+ child.inner_text
270
+ }
271
+
272
+ else
273
+
274
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
275
+
276
+ end
277
+
278
+ }
279
+
280
+ tables << table
281
+
282
+ else
283
+
284
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
285
+
286
+ end
287
+
288
+ }
289
+
290
+ method[ "tables" ] = tables
291
+
292
+ # if element under methods node is unknown...
293
+ else
294
+
295
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
296
+
297
+ end
298
+
299
+ }
300
+
301
+ methods << method
302
+
303
+ }
304
+
305
+ behaviour[ "methods" ] = methods
306
+
307
+
308
+ when /^module$/i
309
+
310
+ behaviour[ child.name.to_s ] = child.attribute("name").value.split(";")
311
+
312
+ else
313
+
314
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
315
+
316
+ end
317
+
318
+ }
319
+
320
+ result[ "behaviours" ] << behaviour
321
+
322
+ when /^text$/i
323
+
324
+ # skip any element inner texts
325
+
326
+ else
327
+
328
+ puts "Unknown element name: '#{ child.name.to_s }' in #{ @current_file }"
329
+
330
+ end
331
+
332
+
333
+ }
334
+
335
+ result
336
+
337
+ end
338
+
339
+ def read_test_result_files( folder )
340
+
341
+ Dir.glob( File.join( folder, '*.xml' ) ).each{ | file |
342
+
343
+ @current_file = file
344
+
345
+ @feature_tests << process_result_file( open( file, 'r' ).read )
346
+
347
+ }
348
+
349
+ puts "\nTest result files: #{ @feature_tests.count }"
350
+
351
+ end
352
+
353
+ def read_behaviour_xml_files( folder )
354
+
355
+ if File.directory?( folder )
356
+
357
+ files = Dir.glob( File.join( folder, '*.xml' ) )
358
+
359
+ else
360
+
361
+ files = [ folder ]
362
+ end
363
+
364
+ files.each{ | file |
365
+
366
+ @current_file = file
367
+
368
+ @behaviours << { :filename => file, :behaviours => process_behaviour_file( open( file, 'r' ).read ) }
369
+
370
+ }
371
+
372
+ puts "Behaviour XML files: #{ @behaviours.count }"
373
+
374
+ end
375
+
376
+ def read_behaviour_hash_files( folder )
377
+
378
+ Dir.glob( File.join( folder, '*.hash' ) ).each{ | file |
379
+
380
+ @current_file = file
381
+
382
+ content = open( file, 'r' ).read
383
+
384
+ # merge to results table
385
+ process_behaviour_hash_file( open( file, 'r' ).read ).each_pair{ | key, value |
386
+
387
+ @behaviour_hashes[ key.to_s ] = ( @behaviour_hashes[ key.to_s ] || [] ) | value
388
+
389
+ }
390
+
391
+ }
392
+
393
+ abort "No behaviour XML files found from folder '#{ folder }'" if @behaviour_hashes.empty?
394
+
395
+ end
396
+
397
+ =begin
398
+ def collect_all_features
399
+
400
+ @behaviour_hashes.collect{ | module_name, methods |
401
+
402
+ methods.collect{ | method |
403
+
404
+ "%s#%s" % [ module_name, method ]
405
+
406
+ }
407
+
408
+ }.flatten
409
+
410
+ end
411
+ =end
412
+
413
+ def collect_documented_features
414
+
415
+ behaviours = {}
416
+
417
+ @behaviours.each{ | behaviour |
418
+
419
+ file_name = behaviour[ :filename ]
420
+
421
+ behaviour_config = behaviour[:behaviours]["__config"] || {}
422
+
423
+ behaviour[:behaviours]["behaviours"].each{ | behaviour |
424
+
425
+ config = Hash[ behaviour.select{ | key, value | key != "methods" } ]
426
+
427
+ # get module name
428
+ module_name = behaviour["module"].first
429
+
430
+ # list methods
431
+ behaviour["methods"].each{ | method |
432
+
433
+ method["name"].each{ | method_name |
434
+
435
+ behaviours[ "%s#%s" % [ module_name, method_name ] ] = method.merge( "__file" => file_name, "__behaviour" => config.merge( behaviour_config ) )
436
+
437
+ }
438
+
439
+ }
440
+
441
+ }
442
+
443
+ }.flatten
444
+
445
+ behaviours
446
+
447
+ end
448
+
449
+ def collect_feature_tests
450
+
451
+ result = {}
452
+
453
+ @feature_tests.collect{ | feature |
454
+
455
+ result[ ( feature["description"] || ["no feature test description"] ).first ] =
456
+
457
+ ( feature["scenarios"] || [] ).collect{ | scenario |
458
+
459
+ # collect step status
460
+ step_results = ( scenario[ "step" ] || [] ).collect{ | step |
461
+
462
+ #p scenario
463
+
464
+ if /^.*\s{1}(\w+)$/.match( step )
465
+
466
+ $1
467
+
468
+ else
469
+
470
+ "unknown"
471
+
472
+ end
473
+
474
+ #( /^.*\s{1}(\w+)$/.match( step ).captures || [] ).first
475
+
476
+ }
477
+
478
+ ( scenario["example_step"] || [] ).collect{ | example |
479
+
480
+ begin
481
+
482
+ code = /\"(.*)\"/m.match( example ).captures.first
483
+
484
+ status = /^.*\s{1}(\w+)$/m.match( example ).captures.first
485
+
486
+ if status.first.to_s.downcase == 'passed'
487
+
488
+ if ( step_results - status ).count > 0
489
+ status_literal = "failed"
490
+ $failed += 1
491
+ else
492
+ status_literal = "passed"
493
+ $passed += 1
494
+ end
495
+
496
+ else
497
+
498
+ if status.first.to_s.empty?
499
+ status_literal = "unknown"
500
+ $unknown += 1
501
+ else
502
+ status_literal = "failed"
503
+ $failed += 1
504
+ end
505
+
506
+ end
507
+
508
+ rescue
509
+
510
+ code = "Error while extracting the code from test"
511
+ status_literal = "unknown"
512
+ $unknown += 1
513
+
514
+ end
515
+
516
+ [
517
+ "example" => code,
518
+ "status" => status_literal,
519
+ "description" => ( scenario["description"] || "" )
520
+ ]
521
+
522
+ }.flatten
523
+
524
+ }.flatten
525
+
526
+ }.flatten
527
+
528
+ result
529
+
530
+ end
531
+
532
+ def generate_document_xml
533
+
534
+ doc = Nokogiri::XML::Builder.new{ | xml |
535
+
536
+ xml.documentation{
537
+
538
+ # TODO: behaviour.hash should have feature type (method/attribute) mentioned
539
+ # TODO: behaviour.hash should have number of arguments incl. optional + blocks
540
+
541
+
542
+ # p @documented_features
543
+
544
+ @documented_features.sort.each{ | feature_name, feature_documentation |
545
+
546
+ feature_documentation.default = ""
547
+
548
+ module_name, method_name = feature_name.split("#")
549
+
550
+ feature_type = feature_documentation[ "type" ].first
551
+
552
+ arguments_count = feature_documentation[ "arguments_data" ][ "implemented" ]
553
+ optional_arguments_count = feature_documentation[ "arguments_data" ][ "optional" ]
554
+
555
+ }
556
+
557
+ #exit
558
+
559
+ @documented_features.sort.each{ | feature, feature_documentation |
560
+
561
+ #module_name, method_name, feature_type, feature_parameters = feature.split("#")
562
+
563
+ #arguments_count, optional_arguments_count = feature_parameters.split(";")
564
+
565
+
566
+
567
+ module_name, method_name = feature.split("#")
568
+
569
+ feature_type = feature_documentation[ "type" ].first
570
+
571
+ arguments_count = feature_documentation[ "arguments_data" ][ "implemented" ]
572
+ optional_arguments_count = feature_documentation[ "arguments_data" ][ "optional" ]
573
+
574
+
575
+ feature = "%s#%s" % [ module_name, method_name ]
576
+
577
+ # make name for feature
578
+ feature_name = case feature_type
579
+
580
+ when "accessor"
581
+ [ method_name, method_name + "=" ]
582
+
583
+ when "writer"
584
+ [ method_name + "=" ]
585
+
586
+ when "reader", "method"
587
+ [ method_name ]
588
+
589
+ else
590
+
591
+ warn("Unknown feature type %s for %s" % [ feature_type, feature ] )
592
+
593
+ [ method_name ]
594
+
595
+ end
596
+
597
+ # get document
598
+
599
+ #documented = @documented_features.keys.include?( feature )
600
+
601
+ #feature_documentation = {}
602
+ #feature_documentation.default = ""
603
+
604
+ # if documented
605
+
606
+ # feature_documentation.merge!( @documented_features[ feature.to_s ] )
607
+
608
+ # end
609
+
610
+ # next if feature_documentation.empty?
611
+
612
+ $features += 1
613
+
614
+ if feature_documentation["nodoc"][0].to_s.downcase == "true"
615
+ $features_nodoc += 1
616
+ next
617
+ end
618
+
619
+ # <feature type="accessor" name="z;z=" types="qt" versions="*" input_types="touch" object_types="*;sut" requires_plugin="x">
620
+ xml.feature(
621
+ :type => feature_type,
622
+ :name => feature_name.join(";"),
623
+ :required_plugin => feature_documentation[ "__behaviour" ][ "plugin" ],
624
+ :sut_type => feature_documentation["__behaviour"][ "sut_type" ].join(";"),
625
+ :sut_version => feature_documentation["__behaviour"][ "version" ].join(";"),
626
+ :input_type => feature_documentation["__behaviour"][ "input_type" ].join(";"),
627
+ :object_type => feature_documentation["__behaviour"][ "object_type" ].join(";")
628
+ ){
629
+
630
+ # <behaviour name="QtGestureBehaviour" module="MobyBehaviour::QT::GestureBehaviour" />
631
+ xml.behaviour(
632
+ :name => feature_documentation[ "__behaviour" ][ "name" ],
633
+ :module => module_name
634
+ )
635
+
636
+ if feature_documentation.has_key?( "deprecated" )
637
+
638
+ xml.deprecated( :version => feature_documentation[ "deprecated" ] )
639
+
640
+ end
641
+
642
+ # <description>example</description>
643
+ xml.description( feature_documentation[ "description" ] )
644
+
645
+ # <info>example</info>
646
+ xml.info( feature_documentation[ "info" ] )
647
+
648
+ feature_documentation[ "arguments" ] = [] if feature_documentation[ "arguments" ].kind_of?( String )
649
+
650
+ # <arguments count="1" optional="0" described="1" block="true">
651
+ xml.arguments(
652
+ :count => arguments_count,
653
+ :optional => optional_arguments_count,
654
+ :described => feature_documentation[ "arguments" ].count,
655
+ :block => feature_documentation[ "arguments" ].select{ | arg | ( arg[ "type" ] || [] ).first == "block" }.count > 0
656
+
657
+ ){
658
+
659
+ ( feature_documentation[ "arguments" ] || [] ).each do | argument |
660
+
661
+ # <argument name="value" optional="false" default="11">
662
+ xml.argument(
663
+ :name => argument[ "name" ].first,
664
+ :optional => argument[ "optional" ].first,
665
+ :default => ( argument[ "default" ] || [] ).first,
666
+ :type => argument[ "type" ].first
667
+
668
+ ){
669
+
670
+ # iterate each argument
671
+ ( argument[ "types" ] || [{}] ).each{ | type |
672
+
673
+ type.each_pair do | argument_type, value |
674
+
675
+ # <type name="Integer">
676
+ xml.type!( :name => argument_type ){
677
+
678
+ # <description>Example argument</description>
679
+ xml.description( value[ "description" ] )
680
+
681
+ # <example>12</example>
682
+ xml.example( value[ "example" ] )
683
+
684
+ } # </type>
685
+
686
+ end # type.each_pair
687
+
688
+ } # arguments_types.each
689
+
690
+ } # </argument>
691
+
692
+ end
693
+
694
+ } # </arguments>
695
+
696
+ # <returns>
697
+ xml.returns( :described => feature_documentation[ "returns" ].size ){
698
+
699
+ ( feature_documentation[ "returns" ] || [{}] ).each do | return_value |
700
+
701
+ # each return value type
702
+ return_value.each_pair do | variable_type, value |
703
+
704
+ # <type name="Integer">
705
+ xml.type_( :name => variable_type ){
706
+
707
+ # <description>Example return value</description>
708
+ xml.description( value[ "description" ] || "" )
709
+
710
+ # <example>12</example>
711
+ xml.example( value[ "example" ] || "" )
712
+
713
+ } # </type>
714
+
715
+ end # types.each
716
+
717
+ end # returns.each
718
+
719
+ } # </returns>
720
+
721
+ # <exceptions>
722
+ xml.exceptions( :described => feature_documentation[ "exceptions" ].size ){
723
+
724
+ ( feature_documentation[ "exceptions" ] || [{}] ).each do | exception |
725
+
726
+ # each exception type
727
+ exception.each_pair do | exception_type, value |
728
+
729
+ # <type name="Integer">
730
+ xml.type_( :name => exception_type ){
731
+
732
+ # <description>Example exception</description>
733
+ xml.description( value[ "description" ] )
734
+
735
+ } # </type>
736
+
737
+ end
738
+
739
+ end
740
+
741
+ } # </exceptions>
742
+
743
+ # <tables>
744
+ xml.tables{
745
+
746
+ ( feature_documentation[ "tables" ] || [{}] ).each do | table |
747
+
748
+ xml.table( :name => table[ "name" ] ){
749
+
750
+ xml.title( table[ "title" ].to_s )
751
+ xml.description( table[ "description" ].to_s )
752
+
753
+ xml.header{
754
+ ( table[ "header" ] || [[]] ).first.each{ | item |
755
+ xml.item( item )
756
+ }
757
+ }
758
+
759
+ ( table[ "row" ] || [] ).each{ | row |
760
+
761
+ xml.row{
762
+ row.each{ | item |
763
+ xml.item( item )
764
+ }
765
+ }
766
+ }
767
+
768
+ }
769
+
770
+ end
771
+
772
+ } # </tables>
773
+
774
+ # collect feature tests for method (1), attr_reader (1), attr_writer (1) and attr_accessor (2)
775
+ names = feature_name.collect{ | name |
776
+
777
+
778
+ feature.split("#").first + "#" + name
779
+
780
+ }
781
+
782
+ tests = names.collect{ | feature_test |
783
+
784
+ { feature_test => @executed_tests[ feature_test ] || {} }
785
+
786
+ }.flatten
787
+
788
+ #p tests
789
+
790
+ # <tests count="1" passed="0" skipped="0" failed="0">
791
+ xml.tests(
792
+ :count => tests.count,
793
+ :passed => tests.select{ | scenario | scenario[ "status" ] == "passed" }.count,
794
+ :skipped => tests.select{ | scenario | scenario[ "status" ] == "skipped" }.count,
795
+ :failed => tests.select{ | scenario | scenario[ "status" ] == "failed" }.count
796
+ ){
797
+
798
+ tests.each do | scenario |
799
+
800
+ scenario.each_pair do | scenario_name, scenarios |
801
+
802
+ scenarios.each do | scenario_value |
803
+
804
+ # <scenario type="reader" status="passed">
805
+ xml.scenario(
806
+
807
+ :type => ( feature_type == "accessor" ? ( ( scenario_name[-1] == ?= ) ? "writer" : "reader" ) : feature_type ),
808
+ :status => scenario_value[ "status" ]
809
+
810
+ ){
811
+
812
+ # <description>Example scenario</description>
813
+ xml.description( scenario_value[ "description" ] )
814
+
815
+ # <example>code</example>
816
+ xml.example( scenario_value[ "example" ] )
817
+
818
+ } # </scenario>
819
+
820
+ end
821
+
822
+ end
823
+
824
+ end
825
+
826
+ } # </tests>
827
+
828
+ }
829
+
830
+ }
831
+
832
+ }
833
+ }
834
+
835
+ doc.to_xml.to_s.gsub("<?xml version=\"1.0\"?>") do | head |
836
+ result = head
837
+ result << "\n"
838
+ result << "<?xml-stylesheet type=\"text/xsl\" href=\"template.xsl\"?>"
839
+ end
840
+
841
+ end
842
+
843
+ if ARGV.count < 2
844
+
845
+ abort "\nUsage: #{ File.basename( $0 ) } test_results_folder behaviour_xml_folder [ output_filename ]\n\n"
846
+
847
+ end
848
+
849
+ feature_tests_folder = File.expand_path( $tests || ARGV[ 0 ] || '.' )
850
+ behaviour_xml_folder = File.expand_path( $source || ARGV[ 1 ] || 'behaviour_xml/' )
851
+ output_filename = File.expand_path( $destination || ARGV[2] || 'document.xml' )
852
+
853
+ read_test_result_files( feature_tests_folder) # ok
854
+ read_behaviour_xml_files( behaviour_xml_folder ) # ok
855
+
856
+ #read_behaviour_hash_files( behaviour_xml_folder ) # ok
857
+
858
+ #puts "all executed feature tests:"
859
+ @executed_tests = collect_feature_tests
860
+
861
+ #puts ""
862
+ #puts "all available features:"
863
+ #@all_features = collect_all_features
864
+
865
+ #puts ""
866
+ #puts "all documented features:"
867
+ @documented_features = collect_documented_features
868
+
869
+ accessors = []
870
+
871
+ puts "\nTotal number of tests: #{ $passed + $failed + $unknown }\n"
872
+ puts "Tests with passed status: #{ $passed }"
873
+ puts "Tests with failed status: #{ $failed }"
874
+ puts "Tests with unknown result: #{ $unknown }"
875
+
876
+
877
+ begin
878
+
879
+ open( output_filename, 'w'){ | file | file << generate_document_xml }
880
+
881
+ puts "\nTotal number of features: #{ $features } (#{ $features_nodoc } with nodoc tag)"
882
+
883
+ puts "\nDocumentation XML saved succesfully to #{ output_filename }"
884
+
885
+ rescue Exception => e
886
+
887
+ puts "\nDocumentation XML saved unsuccesfully due to '#{ e.message }' (#{ e.class })"
888
+
889
+ end
890
+
891
+ puts ""
892
+