microtest 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/.ruby +4 -4
  2. data/History.md +19 -0
  3. data/lib/microtest.rb +35 -5
  4. data/test/test_case.rb +8 -1
  5. metadata +13 -13
data/.ruby CHANGED
@@ -38,12 +38,12 @@ load_path:
38
38
  revision: 0
39
39
  summary: Microminal TestUnit-style Test Framework
40
40
  title: MicroTest
41
- version: 0.1.1
41
+ version: 0.2.0
42
42
  name: microtest
43
- description: ! 'MicroTest is very small Test::Unit/MiniTest compatbile
43
+ description: ! 'MicroTest is a very small Test::Unit/MiniTest compatbile
44
44
 
45
- test framework that run on top of the Ruby Universal
45
+ test framework that runs on top of RubyTest, a Universal
46
46
 
47
- Test Harness (Ruby Test).'
47
+ Test Harness for Ruby.'
48
48
  organization: Rubyworks
49
49
  date: '2012-03-02'
data/History.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Release History
2
2
 
3
+ ## 0.2.0 / 2012-03-03
4
+
5
+ Fix setup and teardown procedures os they run before and after each test,
6
+ not all tests.
7
+
8
+ Changes:
9
+
10
+ * Fix when setup and teardown procedures run.
11
+
12
+
13
+ ## 0.1.1 / 2012-03-02
14
+
15
+ This release consists of just minor tweaks --no functional changes.
16
+
17
+ Changes:
18
+
19
+ * Various admin adjustments.
20
+
21
+
3
22
  ## 0.1.0 / 2011-08-11
4
23
 
5
24
  This first release covers basic compatability with Test::Unit and MiniTest.
data/lib/microtest.rb CHANGED
@@ -1,10 +1,14 @@
1
1
  module MicroTest
2
2
 
3
3
  #
4
+ # Output naturalized test names instead of just method names.
5
+ #
4
6
  def self.natural_names
5
7
  @natural_names ||= nil
6
8
  end
7
9
 
10
+ #
11
+ # Set flag to output naturalized test names instead of just method names.
8
12
  #
9
13
  def self.natural_names=(boolean)
10
14
  @natural_names = !!boolean
@@ -18,53 +22,79 @@ module MicroTest
18
22
  #
19
23
  class TestCase < World
20
24
 
25
+ #
26
+ # When the TestCase class is inherited, a new instance is
27
+ # automatically created.
28
+ #
21
29
  def self.inherited(subclass)
22
30
  subclass.new
23
31
  end
24
32
 
33
+ #
34
+ # Create a new test and add it the the $TEST_SUITE global variable.
25
35
  #
26
36
  def self.new(*a,&b)
27
37
  $TEST_SUITE << super(*a,&b)
28
38
  end
29
39
 
40
+ #
41
+ # Returns name of testcase class.
30
42
  #
31
43
  def to_s
32
44
  self.class.name
33
45
  end
34
46
 
47
+ #
48
+ # Wrap test case run.
49
+ #
50
+ # @todo: Support setup-all and teardown-all in future ?
35
51
  #
36
52
  def call(&cont)
37
- setup
53
+ #setup_all
38
54
  cont.call
39
- teardown
55
+ #teardown_all
40
56
  end
41
57
 
58
+ #
59
+ # Iterate over each test.
42
60
  #
43
61
  def each
44
62
  methods.each do |m|
45
63
  next unless m.to_s.start_with?('test_')
46
- yield(TestMethod.new(method(m)))
64
+ yield(TestMethod.new(self, method(m)))
47
65
  end
48
66
  end
49
67
 
68
+ #
69
+ # No-op for test setup routine.
50
70
  #
51
71
  def setup
52
72
  end
53
73
 
74
+ #
75
+ # No-op for test teardown routine.
54
76
  #
55
77
  def teardown
56
78
  end
57
79
 
58
80
  end
59
81
 
82
+ #
83
+ # Encapsualtes test method for execution by RubyTest. Mainly
84
+ # this separate encapsulation allows the test description to
85
+ # be something other than just the method name, e.g. if the
86
+ # `MicroTest.natural_names` flag is set to true.
60
87
  #
61
88
  class TestMethod
62
- def initialize(method)
63
- @method = method
89
+ def initialize(testcase, method)
90
+ @testcase = testcase
91
+ @method = method
64
92
  end
65
93
 
66
94
  def call
95
+ @testcase.setup
67
96
  @method.call
97
+ @testcase.teardown
68
98
  end
69
99
 
70
100
  def to_s
data/test/test_case.rb CHANGED
@@ -6,8 +6,15 @@ class ExampleTest < MicroTest::TestCase
6
6
  end
7
7
 
8
8
  #
9
- def test_alpha_is_one
9
+ def test_alpha
10
10
  assert_equal(1, @a)
11
+ @a = 2
12
+ end
13
+
14
+ #
15
+ def test_alpha_again
16
+ assert_equal(1, @a)
17
+ @a = 2
11
18
  end
12
19
 
13
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microtest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-02 00:00:00.000000000 Z
12
+ date: 2012-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubytest
16
- requirement: &23971160 !ruby/object:Gem::Requirement
16
+ requirement: &28384060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *23971160
24
+ version_requirements: *28384060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: detroit
27
- requirement: &23970500 !ruby/object:Gem::Requirement
27
+ requirement: &28383360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *23970500
35
+ version_requirements: *28383360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: reap
38
- requirement: &23969840 !ruby/object:Gem::Requirement
38
+ requirement: &28382820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *23969840
46
+ version_requirements: *28382820
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: qed
49
- requirement: &23969280 !ruby/object:Gem::Requirement
49
+ requirement: &28382320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,12 +54,12 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *23969280
58
- description: ! 'MicroTest is very small Test::Unit/MiniTest compatbile
57
+ version_requirements: *28382320
58
+ description: ! 'MicroTest is a very small Test::Unit/MiniTest compatbile
59
59
 
60
- test framework that run on top of the Ruby Universal
60
+ test framework that runs on top of RubyTest, a Universal
61
61
 
62
- Test Harness (Ruby Test).'
62
+ Test Harness for Ruby.'
63
63
  email:
64
64
  - transfire@gmail.com
65
65
  executables: []