dohtest 0.1.4 → 0.1.5

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.
@@ -8,6 +8,10 @@ class GroupRunner
8
8
  @config = config || {}
9
9
  @group_name = @group_class.to_s
10
10
  @group_failed = false
11
+ @tests_ran = 0
12
+ @tests_skipped = 0
13
+ @assertions_passed = 0
14
+ @assertions_failed = 0
11
15
  end
12
16
 
13
17
  def run
@@ -16,7 +20,7 @@ class GroupRunner
16
20
  run_before_all unless @group_failed
17
21
  run_tests unless @group_failed
18
22
  run_after_all unless @group_failed
19
- @output.group_end(@group_name)
23
+ @output.group_end(@group_name, @tests_ran, @tests_skipped, @assertions_passed, @assertions_failed)
20
24
  end
21
25
 
22
26
  def create_group
@@ -52,9 +56,11 @@ class GroupRunner
52
56
  @group.send(:before_each) if has_before_each
53
57
  @output.test_begin(@group_name, @test_name)
54
58
  @group.send(@test_name)
59
+ @tests_ran += 1
55
60
  @output.test_end(@group_name, @test_name)
56
61
  @group.send(:after_each) if has_after_each
57
62
  rescue DohTest::AssertionFailed => failure
63
+ @assertions_failed += 1
58
64
  @output.assertion_failed(@group_name, @test_name, failure)
59
65
  rescue => error
60
66
  @output.test_error(@group_name, @test_name, error)
@@ -64,14 +70,15 @@ class GroupRunner
64
70
 
65
71
  def determine_test_methods
66
72
  @test_methods = @group_class.public_instance_methods.grep(/^test/)
67
- original_test_count = @test_methods.size
68
73
  return unless @config.key?(:grep)
74
+ original_test_count = @test_methods.size
69
75
  grep_filter = Regexp.new(@config[:grep])
70
- @test_methods.select! { |method| name.to_s =~ grep_filter }
71
- @output.tests_skipped(@group_name, original_test_count - @test_methods.size)
76
+ @test_methods.select! { |method| method.to_s =~ grep_filter }
77
+ @tests_skipped = original_test_count - @test_methods.size
72
78
  end
73
79
 
74
80
  def assertion_passed
81
+ @assertions_passed += 1
75
82
  @output.assertion_passed(@group_name, @test_name)
76
83
  end
77
84
  end
@@ -9,11 +9,12 @@ class MasterRunner
9
9
  end
10
10
 
11
11
  def run
12
+ start_time = Time.now
12
13
  DohTest::require_paths(@config[:glob], @paths)
13
14
  srand(@config[:seed])
14
15
  @output.run_begin(@config)
15
16
  TestGroup.descendants.each { |group_class| GroupRunner.new(group_class, @output, @config).run }
16
- @output.run_end
17
+ @output.run_end(Time.now - start_time)
17
18
  end
18
19
  end
19
20
 
@@ -5,7 +5,7 @@ module DohTest
5
5
 
6
6
  class StreamOutput
7
7
  def initialize
8
- @error_count = @group_cnt = @tests_ran = @tests_skipped = @assertions_failed = @assertions_passed = 0
8
+ @error_count = @groups_ran = @groups_skipped = @tests_ran = @tests_skipped = @assertions_failed = @assertions_passed = 0
9
9
  @badness = Set.new
10
10
  end
11
11
 
@@ -13,24 +13,56 @@ class StreamOutput
13
13
  puts "running tests with config: #{config}"
14
14
  end
15
15
 
16
- def run_end
16
+ def run_end(duration)
17
17
  total_assertions = @assertions_passed + @assertions_failed
18
- puts "\n\n#@error_count errors, #@group_cnt groups, #@tests_ran tests, #{@tests_skipped} skipped, #{total_assertions} assertions, #@assertions_passed passed, #@assertions_failed failed"
19
- puts "completed in 0.043702s, 22.8822 tests/s, 45.7645 assertions/s <TODO: put real values here>"
18
+
19
+ if duration >= 1
20
+ tests_per_second = (@tests_ran / duration).round(2)
21
+ assertions_per_second = (total_assertions / duration).round(2)
22
+ puts "\n\ncompleted in #{duration.round(2)}s, #{tests_per_second} tests/s, #{assertions_per_second} assertions/s"
23
+ else
24
+ puts "\n\ncompleted in #{duration.round(2)}s"
25
+ end
26
+
27
+ if @groups_skipped == 0
28
+ groups_str = "#@groups_ran groups"
29
+ else
30
+ total_groups = @groups_ran + @groups_skipped
31
+ groups_str = "#{total_groups} groups: #@groups_ran ran, #@groups_skipped skipped"
32
+ end
33
+
34
+ if @tests_skipped == 0
35
+ tests_str = "#@tests_ran tests"
36
+ else
37
+ total_tests = @tests_ran + @tests_skipped
38
+ tests_str = "#{total_tests} tests: #@tests_ran ran, #@tests_skipped skipped"
39
+ end
40
+
41
+ if @assertions_failed == 0
42
+ assertions_str = "all #{total_assertions} assertions passed"
43
+ else
44
+ assertions_str = "#{total_assertions} assertions: #@assertions_passed passed, #@assertions_failed failed"
45
+ end
46
+ puts "#@error_count errors; #{groups_str}; #{tests_str}; #{assertions_str}"
47
+
20
48
  # this is to generate an exit code; true translates to 0, false to 1
21
49
  @error_count == 0 && @assertions_failed == 0
22
50
  end
23
51
 
24
52
  def group_begin(group_name)
25
- @group_cnt += 1
26
53
  end
27
54
 
28
- def group_end(group_name)
29
- puts "success in #{group_name}" unless @badness.include?(group_name)
30
- end
31
-
32
- def tests_skipped(group_name, count)
33
- @tests_skipped += count
55
+ def group_end(group_name, tests_ran, tests_skipped, assertions_passed, assertions_failed)
56
+ @tests_skipped += tests_skipped
57
+ if tests_ran == 0
58
+ @groups_skipped += 1
59
+ return
60
+ end
61
+ @groups_ran += 1
62
+ total_tests = tests_ran + tests_skipped
63
+ total_assertions = assertions_passed + assertions_failed
64
+ skipped_str = if tests_skipped > 0 then ": #{tests_ran} ran, #{tests_skipped} skipped" else '' end
65
+ puts "success in #{group_name}: #{total_tests} tests#{skipped_str}; #{total_assertions} assertions" unless @badness.include?(group_name)
34
66
  end
35
67
 
36
68
  def test_begin(group_name, test_name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dohtest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-02-23 00:00:00.000000000Z
13
+ date: 2012-02-27 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: dohutil
17
- requirement: &70165913339980 !ruby/object:Gem::Requirement
17
+ requirement: &70361929847060 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: 0.1.5
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70165913339980
25
+ version_requirements: *70361929847060
26
26
  description: Minimalist unit test framework, easy to understand and extend.
27
27
  email:
28
28
  - devinfo@atpsoft.com