fit 1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/README.txt +203 -0
  2. data/Rakefile +111 -0
  3. data/bin/FitServer.rb +6 -0
  4. data/bin/fit +10 -0
  5. data/bin/fit.cgi +36 -0
  6. data/doc/examples/AllCombinations.html +55 -0
  7. data/doc/examples/AllFiles.html +60 -0
  8. data/doc/examples/AllPairs/function/cosine.html +57 -0
  9. data/doc/examples/AllPairs/function/sine.html +57 -0
  10. data/doc/examples/AllPairs/magnitude/180+30.html +45 -0
  11. data/doc/examples/AllPairs/magnitude/30.html +33 -0
  12. data/doc/examples/AllPairs/magnitude/360+30.html +45 -0
  13. data/doc/examples/AllPairs/magnitude/90-30.html +45 -0
  14. data/doc/examples/AllPairs/sign/change-sign.html +27 -0
  15. data/doc/examples/AllPairs/sign/multiply.html +31 -0
  16. data/doc/examples/AllPairs/sign/no-change.html +23 -0
  17. data/doc/examples/AllPairs.html +51 -0
  18. data/doc/examples/BinaryChop.html +89 -0
  19. data/doc/examples/CalculatorExample.html +108 -0
  20. data/doc/examples/ColumnIndex.html +43 -0
  21. data/doc/examples/ExampleTests.html +43 -0
  22. data/doc/examples/FitAcceptanceTests.html +53 -0
  23. data/doc/examples/GeoCoordinate.html +87 -0
  24. data/doc/examples/MusicExample.html +143 -0
  25. data/doc/examples/MusicExampleWithErrors.html +128 -0
  26. data/doc/examples/NetworkExample.html +47 -0
  27. data/doc/examples/WebPageExample.html +92 -0
  28. data/doc/examples/arithmetic.html +211 -0
  29. data/doc/examples/files/hp35bk.jpg +0 -0
  30. data/doc/examples/logo.gif +0 -0
  31. data/doc/fitnesse/FitNesse.RubY.AcceptanceTests.FixtureParameters.html +81 -0
  32. data/doc/fitnesse/FitNesse.RubY.AcceptanceTests.GracefulFixtureNames.html +87 -0
  33. data/doc/fitnesse/FitNesse.RubY.AcceptanceTests.GracefulMemberNames.html +73 -0
  34. data/doc/fitnesse/FitNesse.RubY.AcceptanceTests.ImportFixture.html +61 -0
  35. data/doc/fitnesse/FitNesse.RubY.AcceptanceTests.WaysToSpecifyaFixtureNamespace.html +81 -0
  36. data/doc/spec/annotation.html +3833 -0
  37. data/doc/spec/extensions.html +302 -0
  38. data/doc/spec/fixtures.html +5181 -0
  39. data/doc/spec/index.html +947 -0
  40. data/doc/spec/parse.html +3094 -0
  41. data/lib/eg/all_combinations.rb +44 -0
  42. data/lib/eg/all_files.rb +94 -0
  43. data/lib/eg/all_pairs.rb +172 -0
  44. data/lib/eg/arithmetic_column_fixture.rb +35 -0
  45. data/lib/eg/arithmetic_fixture.rb +29 -0
  46. data/lib/eg/binary_chop.rb +100 -0
  47. data/lib/eg/calculator.rb +69 -0
  48. data/lib/eg/column_index.rb +85 -0
  49. data/lib/eg/division.rb +13 -0
  50. data/lib/eg/echo_args_fixture.rb +9 -0
  51. data/lib/eg/example_tests.rb +84 -0
  52. data/lib/eg/music/Music.txt +38 -0
  53. data/lib/eg/music/browser.rb +60 -0
  54. data/lib/eg/music/display.rb +24 -0
  55. data/lib/eg/music/music.rb +67 -0
  56. data/lib/eg/music/music_library.rb +70 -0
  57. data/lib/eg/music/music_player.rb +77 -0
  58. data/lib/eg/music/realtime.rb +39 -0
  59. data/lib/eg/music/simulator.rb +81 -0
  60. data/lib/eg/nested/bob.rb +12 -0
  61. data/lib/eg/nested/bob_the_builder_fixture.rb +11 -0
  62. data/lib/eg/net/simulator.rb +69 -0
  63. data/lib/eg/page.rb +91 -0
  64. data/lib/eg/sqrt.rb +19 -0
  65. data/lib/fat/annotation_fixture.rb +83 -0
  66. data/lib/fat/color.rb +45 -0
  67. data/lib/fat/divide.rb +13 -0
  68. data/lib/fat/document_parse_fixture.rb +67 -0
  69. data/lib/fat/equals.rb +59 -0
  70. data/lib/fat/fixture_name_fixture.rb +67 -0
  71. data/lib/fat/html_to_text_fixture.rb +20 -0
  72. data/lib/fat/money.rb +18 -0
  73. data/lib/fat/output_fixture.rb +32 -0
  74. data/lib/fat/parse_fixture.rb +92 -0
  75. data/lib/fat/reference_fixture.rb +31 -0
  76. data/lib/fat/standard_annotation_fixture.rb +58 -0
  77. data/lib/fat/string_writer.rb +12 -0
  78. data/lib/fat/table.rb +23 -0
  79. data/lib/fat/table_parse_fixture.rb +33 -0
  80. data/lib/fat/text_to_html_fixture.rb +21 -0
  81. data/lib/fit/action_fixture.rb +65 -0
  82. data/lib/fit/column_fixture.rb +104 -0
  83. data/lib/fit/file_runner.rb +80 -0
  84. data/lib/fit/fit_protocol.rb +62 -0
  85. data/lib/fit/fit_server.rb +173 -0
  86. data/lib/fit/fixture.rb +309 -0
  87. data/lib/fit/fixture_loader.rb +75 -0
  88. data/lib/fit/import_fixture.rb +9 -0
  89. data/lib/fit/parse.rb +206 -0
  90. data/lib/fit/primitive_fixture.rb +52 -0
  91. data/lib/fit/row_fixture.rb +188 -0
  92. data/lib/fit/scientific_double.rb +70 -0
  93. data/lib/fit/summary.rb +46 -0
  94. data/lib/fit/timed_action_fixture.rb +35 -0
  95. data/lib/fit/type_adapter.rb +95 -0
  96. data/lib/fit/wiki_runner.rb +15 -0
  97. data/lib/fittask.rb +184 -0
  98. data/test/all_tests.rb +13 -0
  99. data/test/file_runner_test.rb +52 -0
  100. data/test/fit_server_test.rb +214 -0
  101. data/test/fixture_loader_test.rb +71 -0
  102. data/test/fixture_test.rb +41 -0
  103. data/test/fixtures/fail_fixture.rb +9 -0
  104. data/test/fixtures/pass_fixture.rb +9 -0
  105. data/test/framework_test.rb +51 -0
  106. data/test/parse_test.rb +101 -0
  107. data/test/row_fixture_test.rb +44 -0
  108. data/test/scientific_double_test.rb +35 -0
  109. data/test/type_adapter_test.rb +120 -0
  110. metadata +165 -0
data/README.txt ADDED
@@ -0,0 +1,203 @@
1
+ = RubyFIT -- FIT for Ruby
2
+
3
+ This is RubyFIT, a Ruby port of the original Framework for Interactive
4
+ Testing written in Java by Ward Cunningham. See RubyFIT's home page at
5
+ http://fit.rubyforge.org for further information.
6
+
7
+ Author:: Giulio Piancastelli <giulio.piancastelli@gmail.com>
8
+ Requires:: Ruby 1.8 or later
9
+ License:: RubyFIT is Copyright 2004-2006 by Giulio Piancastelli.
10
+ FIT is Copyright 2002 by Cunningham & Cunningham, Inc.
11
+ Both FIT and RubyFIT are released under the terms of the GNU
12
+ General Public License version 2 or later.
13
+
14
+ Document created on Saturday 11th December, 2004.
15
+ Last revised on Saturday 20th May, 2006.
16
+
17
+ == Quick Start
18
+
19
+ === Unit tests and examples
20
+
21
+ If you want to be sure that at least something is working in the
22
+ framework, the first thing you could do is to run the unit tests that
23
+ accompany RubyFIT. You have the chance of running unit tests during
24
+ the installation of RubyFIT as a gem on your system. (See RubyGems at
25
+ http://rubygems.rubyforge.org and its documentation for details on how
26
+ to do it.) When RubyFIT is installed, you still can run unit tests just
27
+ by moving into its installation directory in the Ruby environment (e.g.
28
+ <tt>$RUBY_HOME/lib/ruby/gems/1.8/gems/fit-1.1/</tt>) and typing +rake+
29
+ at the Terminal or Command Prompt in that directory, which contains
30
+ RubyFIT's Rakefile. If you don't have Rake installed, you can still
31
+ manually run tests by executing the <tt>test/all_tests.rb</tt> script.
32
+
33
+ But the RubyFIT gem also comes with a series of examples directly taken
34
+ from the official FIT wiki (see http://fit.c2.com). HTML files
35
+ containing test data in tables are stored under the
36
+ <tt>doc/examples</tt> directory. If you want to run them to verify that
37
+ the framework passes them, just type <tt>rake fit</tt> at the Terminal
38
+ or Command Prompt in the directory containing RubyFIT's Rakefile.
39
+ Typing <tt>rake fit_report</tt> instead will also have the effect of
40
+ generating reports for those tests, so that you can see green, red,
41
+ yellow and gray cells with your own eyes.
42
+
43
+ The specification for FIT 1.1 compliant implementations is also
44
+ included, in the <tt>doc/spec</tt> directory. Running
45
+ <tt>rake fitspec</tt> or <tt>rake fitspec_report</tt> will have the
46
+ same effects described above in the context of RubyFIT's examples.
47
+
48
+ If you don't have Rake (see http://rake.rubyforge.org) installed, you
49
+ can still running FIT examples and specifications using the command
50
+ line tool provided with the RubyFIT distribution. See next section for
51
+ a brief explanation of its usage.
52
+
53
+ After having verified the capabilities of the framework, you would
54
+ like to start writing your own fixtures testing your applications.
55
+ Follow the online tutorials to understand how to plug into RubyFIT
56
+ and create fixtures and HTML tables with test data.
57
+
58
+ === RubyFIT from the command line
59
+
60
+ A sample command-line script is included in the +bin+ subdirectory of
61
+ the RubyFIT gem to help you run tests in the most painless way. Being
62
+ RubyFIT a gem, the executable scripts to be used as commands from a
63
+ Terminal or Console prompt are made available at any file system
64
+ location.
65
+
66
+ You can invoke the +fit+ script passing two arguments: the first is the
67
+ HTML file containing tables to be tested, the second is the name of the
68
+ HTML file which will be created by RubyFIT and will contain the results
69
+ of the tests.
70
+
71
+ === RubyFIT from a web server
72
+
73
+ A sample CGI script is included in the +bin+ subdirectory of the
74
+ RubyFIT gem, just to let you have a glance at how RubyFIT can be used
75
+ behind a web server. Put <tt>fit.cgi</tt> in the <tt>cgi-bin</tt>
76
+ directory under your web server tree (or in an equivalent appropriate
77
+ location), then change the shebang line to point to the location of the
78
+ Ruby interpreter on your machine. Finally, change the location to
79
+ RubyFIT pointing to the directory you have downloaded the code, and the
80
+ location to your fixtures to whatever directory you use to collect your
81
+ Ruby classes derived from Fit::Fixture.
82
+
83
+ You should now be able to use RubyFIT behind a web server. Write an
84
+ HTML page containing tables for one of your fixtures, and remember to
85
+ add a link to the <tt>fit.cgi</tt> script: serve it through the web
86
+ server you have installed <tt>fit.cgi</tt> within, then click on the
87
+ <tt>fit.cgi</tt> link to run the tests and get a result page in
88
+ response.
89
+
90
+ === RubyFIT from Rake
91
+
92
+ RubyFIT tests can also be run from within the Rake build tool. See the
93
+ online RubyFIT documentation for a brief tutorial on how to use the
94
+ +FitTask+ task in your Rakefile. Visit http://rake.rubyforge.org for
95
+ further details about Rake.
96
+
97
+ === RubyFIT in FitNesse
98
+
99
+ You can now run RubyFIT tests in FitNesse. (See http://fitnesse.org
100
+ for general information on FitNesse.) Define the command pattern like so:
101
+ "!define COMMAND_PATTERN {/path/to/ruby/ruby -I %p -I /path/to/RubyFIT/lib
102
+ /path/to/RubyFIT/bin/FitServer.rb}" changing the paths as appropriate.
103
+
104
+ There is no need to use a separate RubyFIT package to use it from
105
+ within Fitnesse. After installing RubyFIT as a gem in your Ruby
106
+ environment, you can reference the <tt>FitServer.rb</tt> script in
107
+ Fitnesse from the location of the installed gem. For instance you can
108
+ set the latest parameter defining the command pattern to the string
109
+ <tt>/usr/lib/ruby/gems/1.8/gems/fit-1.1/bin/FitServer.rb</tt> for some
110
+ Linux flavors.
111
+
112
+ == RubyFIT Development Issues
113
+
114
+ Being Ruby a much more different language than Java, RubyFIT carries
115
+ some of those unique characteristics, sometimes bulding on them,
116
+ sometimes suffering from them. Here follows a uncomplete list of
117
+ issues in the development of RubyFIT, taken from the examples bundled
118
+ with the RubyFIT distribution.
119
+
120
+ ==== Float Arithmetic
121
+
122
+ In <tt>arithmetic.html</tt> Ruby does math differently from Java. A
123
+ workaround is implemented in Fit::TypeAdapter#equals: if one of the
124
+ object is a Float and the other is a Numeric, equality is tested on a
125
+ 1.0e-5 delta. Also, in <tt>CalculatorExample.html</tt> Ruby does Floats
126
+ with much more precision than Java, so that even a 1.0e-15 or -1.0e-17
127
+ difference is retained. A workaround in Fit::ScientificDouble has been
128
+ implemented, so that if the precision is exactly zero, the values of
129
+ two comparing objects must be equals in a 1.0e-5 delta.
130
+
131
+ Note than in <tt>AllCombinations.html</tt> Ruby does even
132
+ ScientificDouble with much more precision than the Java version. So,
133
+ another workaround in <tt>==</tt> and <tt><=></tt> had to be employed,
134
+ specifically to create another ScientificDouble to compare with and to
135
+ pick the precision of the less precise of the two to make the
136
+ comparison.
137
+
138
+ ==== Reflection in Fit::Fixture
139
+
140
+ Being Ruby a dynamically typed programming language, it does not hold
141
+ static typing information about fields and values returned from
142
+ methods. The FIT framework instead uses those information to make
143
+ automatic comparisons between expected and actual results while running
144
+ tests using HTML tables as input data.
145
+
146
+ RubyFIT covers that mechanisms for basic types only. When a fixture
147
+ uses custom types instead, some additional static metadata must be
148
+ provided to let the framework know about types of fields and return
149
+ types of methods.
150
+
151
+ The online tutorials provide some examples on using metadata in
152
+ fixtures and related classes.
153
+
154
+ ==== Class names from 'eg.AllFiles$Example' strings in Fit::Fixture
155
+
156
+ The syntax of fixtures class names into HTML tables is directly taken
157
+ from the Java world, where FIT was originally being developed. The
158
+ fully specified name of a class in Java is typically composed by a
159
+ series of words separated by dots: the last word is the name of the
160
+ class, while the other words identify the packages in which that class
161
+ is contained. RubyFIT translates those names into Ruby class names: the
162
+ name of the class remains unchanged, while package names (typically
163
+ written in lower case as per Java conventions) get capitalized; the
164
+ double colon is used instead of the dot as a separator between names.
165
+
166
+ A particular syntax is used in the Java world for inner classes, i.e.
167
+ classes defined inside other classes: in this case, a dollar sign is
168
+ used as a separator between the names of the parent and the child
169
+ classes. RubyFIT just translates the separator into a double colon,
170
+ leaving class names untouched.
171
+
172
+ ==== Method names from HTML in Fit::TypeAdapter
173
+
174
+ RubyFIT uses Fitnesse-style graceful naming, modified to suit Ruby's
175
+ syntax and customs. For example, given any of these names in a row or
176
+ column fixture: <tt>some_method()</tt>, <tt>some method()</tt>,
177
+ <tt>some*method()</tt>, <tt>SomeMethod()</tt>, or
178
+ <tt>Some Method()</tt>, it will call the method +some_method+,
179
+ expecting it to be an output method (or getter), or the equivelent
180
+ accessor generated by +attr_reader+. Given any of the above names, with
181
+ the <tt>()</tt> replaced by <tt>?</tt>, such as <tt>some method?</tt>
182
+ it will match the same methods, but will prefer a method named
183
+ <tt>some_method?</tt>, if it exists. Any of the above names, with the
184
+ <tt>()</tt> removed (and no <tt>?</tt>) will be interpreted as an input
185
+ method (or setter) and will match <tt>some_method=(value)</tt>, as well
186
+ as mutators generated by +attr_writer+.
187
+
188
+ == Acknowledgements
189
+
190
+ === Credits
191
+
192
+ The main developer and project maintainer is Giulio Piancastelli.
193
+
194
+ Other developers have contributed code to the project:
195
+ - Micah Martin
196
+ - Jim Hughes
197
+ - Brian Marick
198
+ - Bret Pettichord
199
+
200
+ === Special Thanks
201
+
202
+ Thanks to Ward Cunningham for creating FIT, and to Jim Shore for
203
+ coordinating the effort of porting FIT to platforms other than Java.
data/Rakefile ADDED
@@ -0,0 +1,111 @@
1
+ require 'rake/clean'
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), 'lib')
4
+ require 'fittask'
5
+
6
+ desc "Run Fit TaskLib"
7
+ Rake::FitTask.new(:fit) do |t|
8
+ # t.libs = ["lib/fit/*.rb"] # the fixture directory goes here
9
+
10
+ t.fail_on_failed_test = true
11
+ t.create_test_suite do |suite|
12
+ suite.test_path = 'doc/fitnesse/'
13
+ suite.report_path = 'doc/fitnesse/reports/'
14
+ test_files = Dir.glob(suite.test_path + '/*.html')
15
+ suite.tests = test_files.collect do |test_file|
16
+ { :name => File.basename(test_file, '.html') }
17
+ end
18
+ end
19
+
20
+ examples = []
21
+ examples << { :name => 'arithmetic',
22
+ :right => 39, :wrong => 8, :ignores => 0, :exceptions => 2 }
23
+ examples << { :name => 'BinaryChop',
24
+ :right => 95, :wrong => 0, :ignores => 0, :exceptions => 0 }
25
+ examples << { :name => 'CalculatorExample',
26
+ :right => 75, :wrong => 9, :ignores => 0, :exceptions => 0 }
27
+ examples << { :name => 'MusicExample',
28
+ :right => 95, :wrong => 0, :ignores => 0, :exceptions => 0 }
29
+ examples << { :name => 'MusicExampleWithErrors',
30
+ :right => 54, :wrong => 10, :ignores => 0, :exceptions => 0 }
31
+ # WebPageExample is not here because it needs an active Internet connection
32
+ examples << { :name => 'NetworkExample',
33
+ :right => 5, :wrong => 0, :ignores => 0, :exceptions => 0 }
34
+ examples << { :name => 'ColumnIndex',
35
+ :right => 51, :wrong => 3, :ignores => 8, :exceptions => 0 }
36
+ examples << { :name => 'AllFiles',
37
+ :right => 9, :wrong => 3, :ignores => 0, :exceptions => 0 }
38
+ examples << { :name => 'AllCombinations',
39
+ :right => 72, :wrong => 14, :ignores => 0, :exceptions => 0 }
40
+ examples << { :name => 'AllPairs',
41
+ :right => 39, :wrong => 9, :ignores => 0, :exceptions => 0 }
42
+ # Running the ExampleTests.html file is roughly equivalent to this test suite
43
+ t.create_test_suite do |suite|
44
+ suite.test_path = "doc/examples/"
45
+ suite.report_path = "doc/reports/"
46
+ suite.tests = examples
47
+ end
48
+
49
+ t.test_suites.each do |suite|
50
+ CLOBBER.include(suite.report_path + "Report_*.html")
51
+ CLOBBER.include(suite.report_path + "footnotes/")
52
+ end
53
+
54
+ end
55
+
56
+ Rake::FitTask.new(:fitspec) do |t|
57
+ t.create_test_suite do |suite|
58
+ suite.test_path = "doc/spec/"
59
+ suite.report_path = "doc/spec/"
60
+ suite << { :name => 'parse',
61
+ :right => 70, :wrong => 0, :ignores => 0, :exceptions => 0 }
62
+ suite << { :name => 'annotation',
63
+ :right => 47, :wrong => 0, :ignores => 0, :exceptions => 0 }
64
+ end
65
+ end
66
+
67
+ require 'rake/testtask'
68
+
69
+ desc "Default task is to run FIT unit tests."
70
+ task :default => :test
71
+
72
+ desc "Run FIT unit tests."
73
+ Rake::TestTask.new do |t|
74
+ t.test_files = FileList['test/all_tests.rb']
75
+ t.verbose = true
76
+ t.libs = ['lib','test'] # verify why is needed
77
+ end
78
+
79
+ ### RubyGems related stuff
80
+
81
+ require 'rake/gempackagetask'
82
+
83
+ spec = Gem::Specification.new do |s|
84
+ s.name = 'fit'
85
+ s.version = '1.1'
86
+ s.author = 'Giulio Piancastelli'
87
+ # See the README for other authors/developers/contributors
88
+ s.email = 'giulio.piancastelli@gmail.com'
89
+ s.homepage = 'http://fit.rubyforge.org/'
90
+ s.rubyforge_project = 'fit'
91
+ s.platform = Gem::Platform::RUBY
92
+ s.summary = 'A Ruby port of FIT (Framework for Integrated Testing)'
93
+ s.files = FileList["{bin,lib,test,doc}/**/*"].to_a + ["Rakefile"]
94
+ s.require_path = 'lib'
95
+ # s.autorequire something?
96
+ # set for executable scripts in the bin/ subdirectory
97
+ s.bindir = 'bin'
98
+ s.executables << 'fit'
99
+ s.test_file = 'test/all_tests.rb'
100
+ s.has_rdoc = false # no RDoc comments in the code
101
+ s.extra_rdoc_files = ["README.txt"]
102
+ # no external dependencies on other gems
103
+ end
104
+
105
+ # Cygwin's ln fails under my Windows installation
106
+ FileUtils::LN_SUPPORTED[0] = false
107
+
108
+ Rake::GemPackageTask.new(spec) do |pkg|
109
+ pkg.need_tar = true
110
+ pkg.need_zip = true
111
+ end
data/bin/FitServer.rb ADDED
@@ -0,0 +1,6 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
+
3
+ require 'fit/fit_server'
4
+
5
+ exitCode = Fit::FitServer.new.run(ARGV)
6
+ exit exitCode
data/bin/fit ADDED
@@ -0,0 +1,10 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
+
3
+ require 'fit/parse'
4
+ require 'fit/file_runner'
5
+
6
+ report = ARGV[1]
7
+ unless report.nil?
8
+ Fit::Parse.footnote_path = File.dirname(report) + File::SEPARATOR
9
+ end
10
+ Fit::FileRunner.new.run ARGV
data/bin/fit.cgi ADDED
@@ -0,0 +1,36 @@
1
+ #!C:/Programmi/Ruby18/bin/ruby
2
+
3
+ require 'cgi'
4
+ require 'open-uri'
5
+
6
+ # Set the location of the RubyFIT installation on your machine
7
+ rubyfit_location = "D:/Progetti/Ruby/Fit/lib"
8
+ # Set the location of the newly-created pure-Ruby fixtures on your machine
9
+ # rubyfit_fixtures = "D:/Progetti/Ruby/Fit/MyFixtures"
10
+ rubyfit_fixtures = "D:/Progetti/Ruby/Fit/examples"
11
+
12
+ $:.unshift(rubyfit_location, rubyfit_fixtures)
13
+
14
+ require 'fit/file_runner'
15
+
16
+ cgi = CGI.new
17
+
18
+ input_name = 'fitDocument.html'
19
+ output_name = 'fitReport.html'
20
+
21
+ referer = cgi.referer
22
+ begin
23
+ input = open(referer) {|stream| stream.read}
24
+ File.open(input_name, 'w') {|f| f.write(input)}
25
+ runner = Fit::FileRunner.new
26
+ runner.process_args [input_name, output_name]
27
+ runner.process
28
+
29
+ output = File.open(output_name) {|f| f.read}
30
+ cgi.out { output }
31
+
32
+ File.delete(output_name)
33
+ File.delete(input_name)
34
+ rescue Exception => e
35
+ cgi.out {e.message + "\n" + e.backtrace.join("\n")}
36
+ end
@@ -0,0 +1,55 @@
1
+ <html>
2
+ <head>
3
+ <title>Wiki: All Combinations</title>
4
+ <head>
5
+ <body bgcolor=#FFFFFF link=#d06040 vlink=#806040>
6
+ <h1>All Combinations</h1>
7
+ <wiki>This is the second of a suite of fixtures that make up the AllPairsExample. Like with AllFiles, we expand wildcard characters in path specifications to get lists of tests. But this time we run all combinations of the tests. This is another warmup for AllPairs testing.
8
+ <p><p><hr>
9
+ <p>A project can expect to have dozens or hundreds of files testing specific features in a stand-alone way. We may wonder if there are any interactions between features that will cause any of these tests to fail. AllCombinations explores this. It is a fixture that enumerates cases by drawing one file at a time from each of a number of lists; running each in turn, and then repeating the drawing and running for all possible combinations.
10
+ <p>For the purpose of illustration we've created a number of files that contain small tests of the CalculatorExample. We've categorized the files as <em>magnitudes, signs</em> and <em>functions,</em> which enter values, changes signs, and compute functions, respectivly.
11
+ <p><UL>
12
+ <li> <a href="Release/Documents/AllPairs/">http:Release/Documents/AllPairs/</a>
13
+ <p></UL>
14
+ This table runs all possible sequences of magnitude, sign and function. Try it with <a href="run.cgi">http:run.cgi</a>.
15
+ <p><table BORDER CELLSPACING=0 CELLPADDING=3>
16
+ <tr><td ColSpan=2> eg.AllCombinations </td></tr>
17
+ <tr><td> doc/examples/AllPairs/magnitude/*.html </td><td>&nbsp;</td></tr>
18
+ <tr><td> doc/examples/AllPairs/sign/*.html </td><td>&nbsp;</td></tr>
19
+ <tr><td> doc/examples/AllPairs/function/*.html </td><td>&nbsp;</td></tr>
20
+ </table>
21
+ <p>The number of cases will as large as the product of the size of each list of tests. The searches in the table find four magnitues, three signs and two functions.
22
+ <p><UL>
23
+ <li> 4 magnitudes X 3 signs X 2 functions = 24 cases
24
+ <p></UL>
25
+ Any file of any case can fail. We save the results from failed tests only. A single file can fail different ways in different cases. Look for differences in the counts or examine each FileFootnote.
26
+ <p>If the tests are intended to interact, as ours are here, then some care is required to be sure that checks in the tests are independent of this interaction. No checks at all my be suitable if we are only testing that there are no exceptions thrown. Or the simplest checks may be adaquate so long as features are tested well in isolation. It may be convenient to run a simulation, a so called <em>oracale</em>, along side the application to generate expected results.
27
+ <p><hr>
28
+ <p><strong>Implementation</strong>
29
+ <p>The fixture inherits path expansion from AllFiles, but captures these by overrinding <em>doRows(Parse, List)</em> and saving the list of files in a list of lists. Then, at the end of <em>doTable</em>, the fixture gets to work computing and running combinations.
30
+ <p>See source.
31
+ <p><UL>
32
+ <li> <a href="Release/Source/eg/AllCombinations.java">http:Release/Source/eg/AllCombinations.java</a>
33
+ <p></UL>
34
+ We had a little trouble setting up the test data for this example so we wrote this little <em>Trigonometry Refresher</em>.
35
+ <p><table BORDER CELLSPACING=0 CELLPADDING=3>
36
+ <tr><td ColSpan=3> eg.ArithmeticColumnFixture </td></tr>
37
+ <tr><td> x </td><td> sin() </td><td> cos() </td></tr>
38
+ <tr><td> 0 </td><td> 0.0000 </td><td> 1.0000 </td></tr>
39
+ <tr><td> 30 </td><td> 0.5000 </td><td> 0.8660 </td></tr>
40
+ <tr><td> 60 </td><td> 0.8660 </td><td> 0.5000 </td></tr>
41
+ <tr><td> 90 </td><td> 1.0000 </td><td> 0.0000 </td></tr>
42
+ <tr><td> 120 </td><td> 0.8660 </td><td> -0.5000 </td></tr>
43
+ <tr><td> 150 </td><td> 0.5000 </td><td> -.8660 </td></tr>
44
+ <tr><td> 180 </td><td> 0.0000 </td><td> -1.0000 </td></tr>
45
+ </table>
46
+ <p><hr>
47
+ <p><p><table BORDER CELLSPACING=0 CELLPADDING=3>
48
+ <tr><td ColSpan=2> fit.Summary </td></tr>
49
+ </table>
50
+ <p></wiki>
51
+ <hr>
52
+ Last edited November 4, 2002
53
+ </body>
54
+ </html>
55
+
@@ -0,0 +1,60 @@
1
+ <html>
2
+ <head>
3
+ <title>Wiki: All Files</title>
4
+ <head>
5
+ <body bgcolor=#FFFFFF link=#d06040 vlink=#806040>
6
+ <h1>All Files</h1>
7
+ <wiki>This is the first of a suite of fixtures that make up the AllPairsExample. It and AllCombinations are warmups for AllPairs testing.
8
+ <p><hr>
9
+ <p>A project can expect to have dozens to hundreds of files filled with specifications, explainations and associated tests. The AllFiles fixture seeks out these files and runs them all, one after another, and reports a "rolled-up" accounting of their results.
10
+ <p>Like the ExampleTests fixture, the AllFiles fixture will take as its tabular input a list of files to be run. But here, unlike that fixture, we will expand wildcard characters in order to find all the tests in a particular place, whether we know what they are now or not.
11
+ <p>Here are wildcard path expressions that find lots of other tests. Try runing them with <a href="run.cgi">http:run.cgi</a>.
12
+ <p><table BORDER CELLSPACING=0 CELLPADDING=3>
13
+ <tr><td ColSpan=2> eg.AllFiles </td></tr>
14
+ <tr><td> doc/examples/*Example.html </td><td>&nbsp;</td></tr>
15
+ <tr><td> doc/examples/Music*.html </td><td>&nbsp;</td></tr>
16
+ </table>
17
+ <p>The AllFiles fixture adds rows to this table for each of the files it finds. The first column is the expanded file name, the second, the resulting counts for that run. We mark the results "wrong" if there are any wrongs or exceptions. That means the above tests will never pass because we have intentional errors in these files.
18
+ <p>Use AllFiles when you expect all your tests to pass and only want to know when this expectation is unfounded. AllFiles does not create output files for the tests it runs unless there is a problem. Problem run results are saved and cited along with the counts in a FileFootnote that looks like [1], [2], and so on.
19
+ <p>Test counts can sore when we start running files over and over. LessonsLearned advise us to not take big "right" counts too seriously so we don't. In fact a file with 100 right and no wrong counts as 1 right from this fixtures perspective. You can see this in the <em>counts</em> reported in the summary:
20
+ <p><table BORDER CELLSPACING=0 CELLPADDING=3>
21
+ <tr><td ColSpan=2> fit.Summary </td></tr>
22
+ </table>
23
+ <p>(Note: See more complete summary below.)
24
+ <p>You will also note that the fixture reports total counts for the files it runs under <em>counts run</em> in the summary because, lessons not withstanding, we like to know.
25
+ <p><hr>
26
+ <p><strong>Implementation</strong>
27
+ <p>The fixture distinguishes expandings the path specifications (doRow) from running the list of files produced (doFiles). This fixture does the files as they are expanded. The AllCombinations and AllPairs refinements expand all rows before they start doing.
28
+ <p>The path expansion only expands one wildcard character, star (*), which means <em>any characters</em> here. The star can appear anywhere in a name and in any or all names that make up a path. But the expansion we've coded has the restriction that only one star is expanded in any component of the path.
29
+ <p>The expanded file names will refer to files that may or may not use the &lt;wiki&gt; tag convention (See WikiRunner). This fixture is happy to run either file format and lets the presence of a &lt;wiki&gt; tag in the file indicate the need for its processing.
30
+ <p>See the source.
31
+ <p><UL>
32
+ <li> <a href="Release/Source/eg/AllFiles.java">http:Release/Source/eg/AllFiles.java</a>
33
+ <p></UL>
34
+ This class includes an implementation of FileFootnote that is discussed on that page.
35
+ <p><hr>
36
+ <p><table BORDER CELLSPACING=0 CELLPADDING=3>
37
+ <tr><td ColSpan=2> eg.AllFiles$Expand </td></tr>
38
+ <tr><td> path </td><td> expansion() </td></tr>
39
+ <tr><td> doc/examples/*Example.html </td><td> CalculatorExample.html,MusicExample.html,NetworkExample.html,WebPageExample.html </td></tr>
40
+ <tr><td> doc/examples/Music*.html </td><td> MusicExample.html,MusicExampleWithErrors.html </td></tr>
41
+ <tr><td> doc/examples/AllPairs/magnitude/*.html </td><td> 180+30.html,30.html,360+30.html,90-30.html </td></tr>
42
+ <tr><td> doc/examples/AllPairs/sign/*.html </td><td> change-sign.html,multiply.html,no-change.html </td></tr>
43
+ <tr><td> doc/examples/AllPairs/function/*.html </td><td> cosine.html,sine.html </td></tr>
44
+ <tr><td> doc/examples/AllPairs/function/*sine.html </td><td> cosine.html,sine.html </td></tr>
45
+ <tr><td> doc/examples/AllPairs/function/*.xml </td><td>&nbsp;</td></tr>
46
+ <tr><td> doc/examples/AllPairs/func* </td><td>&nbsp;</td></tr>
47
+ <tr><td> doc/examples/AllPairs/* </td><td>&nbsp;</td></tr>
48
+ <tr><td> doc/examples/AllPairs* </td><td>&nbsp;</td></tr>
49
+ <tr><td> doc/examples/* </td><td>&nbsp;</td></tr>
50
+ </table>
51
+ <p>We've added some more tests to this document so the totals in the summary increase.
52
+ <p><table BORDER CELLSPACING=0 CELLPADDING=3>
53
+ <tr><td ColSpan=2> fit.Summary </td></tr>
54
+ </table>
55
+ <p></wiki>
56
+ <hr>
57
+ Last edited April 20, 2003
58
+ </body>
59
+ </html>
60
+
@@ -0,0 +1,57 @@
1
+ <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+ <meta name="GENERATOR" content="Mozilla/4.77C-CCK-MCD {C-UDP; EBM-APPLE} (Macintosh; U; PPC) [Netscape]">
6
+ <title>change-sign.html</title>
7
+ </head>
8
+ <body>
9
+ Check cosine function.
10
+ <br>&nbsp;
11
+ <table BORDER CELLSPACING=0 CELLPADDING=3 >
12
+ <tr>
13
+ <td>eg.Calculator</td>
14
+
15
+ <td>&nbsp;</td>
16
+ </tr>
17
+
18
+ <tr>
19
+ <td>key</td>
20
+
21
+ <td>x()</td>
22
+ </tr>
23
+
24
+ <tr>
25
+ <td>enter</td>
26
+
27
+ <td></td>
28
+ </tr>
29
+
30
+ <tr>
31
+ <td>cos</td>
32
+
33
+ <td></td>
34
+ </tr>
35
+
36
+ <tr>
37
+ <td>enter</td>
38
+
39
+ <td></td>
40
+ </tr>
41
+
42
+ <tr>
43
+ <td>*</td>
44
+
45
+ <td></td>
46
+ </tr>
47
+
48
+ <tr>
49
+ <td>sqrt</td>
50
+
51
+ <td>0.8660</td>
52
+ </tr>
53
+ </table>
54
+
55
+ <p>See <a href="http://fit.c2.com/wiki.cgi?AllPairsExample">AllPairsExample</a>.
56
+ </body>
57
+ </html>
@@ -0,0 +1,57 @@
1
+ <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+ <meta name="GENERATOR" content="Mozilla/4.77C-CCK-MCD {C-UDP; EBM-APPLE} (Macintosh; U; PPC) [Netscape]">
6
+ <title>change-sign.html</title>
7
+ </head>
8
+ <body>
9
+ Check sine function.
10
+ <br>&nbsp;
11
+ <table BORDER CELLSPACING=0 CELLPADDING=3 >
12
+ <tr>
13
+ <td>eg.Calculator</td>
14
+
15
+ <td>&nbsp;</td>
16
+ </tr>
17
+
18
+ <tr>
19
+ <td>key</td>
20
+
21
+ <td>x()</td>
22
+ </tr>
23
+
24
+ <tr>
25
+ <td>enter</td>
26
+
27
+ <td></td>
28
+ </tr>
29
+
30
+ <tr>
31
+ <td>sin</td>
32
+
33
+ <td></td>
34
+ </tr>
35
+
36
+ <tr>
37
+ <td>enter</td>
38
+
39
+ <td></td>
40
+ </tr>
41
+
42
+ <tr>
43
+ <td>*</td>
44
+
45
+ <td></td>
46
+ </tr>
47
+
48
+ <tr>
49
+ <td>sqrt</td>
50
+
51
+ <td>0.5000</td>
52
+ </tr>
53
+ </table>
54
+
55
+ <p>See <a href="http://fit.c2.com/wiki.cgi?AllPairsExample">AllPairsExample</a>.
56
+ </body>
57
+ </html>
@@ -0,0 +1,45 @@
1
+ <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
+ <meta name="GENERATOR" content="Mozilla/4.77C-CCK-MCD {C-UDP; EBM-APPLE} (Macintosh; U; PPC) [Netscape]">
6
+ <title>change-sign.html</title>
7
+ </head>
8
+ <body>
9
+ Enter 180+30 degrees.
10
+ <br>&nbsp;
11
+ <table BORDER CELLSPACING=0 CELLPADDING=3 >
12
+ <tr>
13
+ <td>eg.Calculator</td>
14
+
15
+ <td></td>
16
+ </tr>
17
+
18
+ <tr>
19
+ <td>key</td>
20
+
21
+ <td>x()</td>
22
+ </tr>
23
+
24
+ <tr>
25
+ <td>180</td>
26
+
27
+ <td>&nbsp;</td>
28
+ </tr>
29
+
30
+ <tr>
31
+ <td>30</td>
32
+
33
+ <td>&nbsp;</td>
34
+ </tr>
35
+
36
+ <tr>
37
+ <td>+</td>
38
+
39
+ <td>&nbsp;210.000</td>
40
+ </tr>
41
+ </table>
42
+
43
+ <p>See <a href="http://fit.c2.com/wiki.cgi?AllPairsExample">AllPairsExample</a>.
44
+ </body>
45
+ </html>