test-output-parser 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11363d44bb20be392cf0c364aca640d4e6765d15
4
- data.tar.gz: 704481936d666f8968aeffe2740a61b81b68b9a0
3
+ metadata.gz: af6f80610f90a75280a15fd9ae8a0c93d7991d6b
4
+ data.tar.gz: 375e847ab92cc5c02c7ec3c9cda9d07992e63ead
5
5
  SHA512:
6
- metadata.gz: bebc1c57b4e1d95776e36d4bbc1bf21d0972b1a5af56e78041a36277c5e9bc8ba5caf75fd9dde9edbb7b83b18f38e31d5759247a5abbc3fd9d70564d27774ddb
7
- data.tar.gz: bc74317300f4cdd5952803377f16620ece6607e78824d5dfe198a98f33a0a13ffd94c843a6d96210f39c2dd246f760c8bbbac3857d9ca76f323d453dc46531ad
6
+ metadata.gz: a1f711eb3266edd2457d83a9b5694c23fd2b244bcbbf936b7e1f76cd40f78b30c2ae57309aa011386fd5083dfe5c46ba550ade9d8a077cd324b23ba6e60ad029
7
+ data.tar.gz: 2c9faab045e24dce8a4ea1aa3757e7ca856fd762e69ac9a49e11b195ad3ad3cd13184528aae5b0f8850359261904aee33270f0d4916d13e8a5975a2058fecf72
@@ -2,10 +2,8 @@ require 'test_output_parser/version'
2
2
  require 'test_output_parser/framework'
3
3
 
4
4
  module TestOutputParser
5
- def self.count(test_output, framework)
6
- return TestOutputParser::Framework::RSpec.count(test_output) if framework == :rspec
7
- return TestOutputParser::Framework::TestUnit.count(test_output) if framework == :test_unit
8
-
9
- raise ArgumentError.new("Invalid argument")
5
+ def self.count(test_output)
6
+ summary = TestOutputParser::Framework::RSpec.count(test_output)
7
+ TestOutputParser::Framework::TestUnit.count(test_output, summary)
10
8
  end
11
9
  end
@@ -3,5 +3,8 @@ require 'test_output_parser/framework/test_unit'
3
3
 
4
4
  module TestOutputParser
5
5
  module Framework
6
+ def count(test_output)
7
+ raise 'Sub class responsibility'
8
+ end
6
9
  end
7
10
  end
@@ -1,8 +1,7 @@
1
1
  module TestOutputParser
2
2
  module Framework
3
3
  class RSpec
4
- def self.count(test_output)
5
- summary = Hash.new(0)
4
+ def self.count(test_output, summary=Hash.new(0))
6
5
  test_output.scan(/(\d+)\s+example[s]?,\s+(\d+)\s+failure[s]?(,\s*(\d+)\s+pending)?/).each do |arr|
7
6
  summary[:total] += arr[0].to_i
8
7
  summary[:failed] += arr[1].to_i
@@ -1,14 +1,13 @@
1
1
  module TestOutputParser
2
2
  module Framework
3
3
  class TestUnit
4
- def self.count(test_output)
5
- summary = Hash.new(0)
4
+ def self.count(test_output, summary=Hash.new(0))
6
5
  test_output.scan(/(\d+)\s+test[s]?,\s+(\d+)\s+assertion[s]?(,\s*(\d+)\s+failures)?(,\s*(\d+)\s+error[s]?)?(,\s*(\d+)\s+skip[s]?)?/).each do |arr|
7
6
  summary[:total] += arr[0].to_i
8
- summary[:assertions] += arr[1].to_i
7
+ #summary[:assertions] += arr[1].to_i
9
8
  summary[:failed] += arr[3].to_i
10
9
  summary[:errors] += arr[5].to_i
11
- summary[:skipped] += arr[7].to_i
10
+ summary[:pending] += arr[7].to_i
12
11
  end
13
12
 
14
13
  summary
@@ -1,3 +1,3 @@
1
1
  module TestOutputParser
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -6,32 +6,32 @@ describe TestOutputParser::Framework::TestUnit do
6
6
  end
7
7
 
8
8
  it 'should count the number of tests ran for one test' do
9
- TestOutputParser::Framework::TestUnit.count("1 tests, 1 assertions").should == {:total => 1, :assertions => 1, :failed => 0, :errors => 0, :skipped => 0}
9
+ TestOutputParser::Framework::TestUnit.count("1 tests, 1 assertions").should == {:total => 1, :failed => 0, :errors => 0, :pending => 0}
10
10
  end
11
11
 
12
12
  it 'should count the number of specs ran for one test-unit run' do
13
13
  TestOutputParser::Framework::TestUnit.count("30 tests, 77 assertions, 3 failures, 4 errors, 2 skips").should ==
14
- {:total => 30, :assertions => 77, :failed => 3, :errors => 4, :skipped => 2}
14
+ {:total => 30, :failed => 3, :errors => 4, :pending => 2}
15
15
  end
16
16
 
17
17
  it 'should count the number of specs ran for multiple test-unit runs' do
18
18
  TestOutputParser::Framework::TestUnit.count("30 tests, 77 assertions, 0 failures\n\n\n1 tests, 3 assertions, 1 failures, 1 errors, 1 skips").should ==
19
- {:total => 31, :assertions => 80, :failed => 1, :errors => 1, :skipped => 1}
19
+ {:total => 31, :failed => 1, :errors => 1, :pending => 1}
20
20
  end
21
21
 
22
22
  it 'should ignore lines not related to test-unit test summary' do
23
- TestOutputParser::Framework::TestUnit.count(File.read("spec/fixtures/sample-test-unit-output.txt")).should == {:total => 1, :assertions => 1, :failed => 0, :errors => 0, :skipped => 0}
23
+ TestOutputParser::Framework::TestUnit.count(File.read("spec/fixtures/sample-test-unit-output.txt")).should == {:total => 1, :failed => 0, :errors => 0, :pending => 0}
24
24
  end
25
25
 
26
26
  it 'should count failures correctly' do
27
- TestOutputParser::Framework::TestUnit.count(File.read("spec/fixtures/sample-failed-test-unit-output.txt")).should == {:total => 1, :assertions => 1, :failed => 1, :errors => 0, :skipped => 0}
27
+ TestOutputParser::Framework::TestUnit.count(File.read("spec/fixtures/sample-failed-test-unit-output.txt")).should == {:total => 1, :failed => 1, :errors => 0, :pending => 0}
28
28
  end
29
29
 
30
30
  it 'should count the number of specs errors' do
31
- TestOutputParser::Framework::TestUnit.count(File.read("spec/fixtures/sample-error-test-unit-output.txt")).should == {:total => 1, :assertions => 1, :failed => 0, :errors => 1, :skipped => 0}
31
+ TestOutputParser::Framework::TestUnit.count(File.read("spec/fixtures/sample-error-test-unit-output.txt")).should == {:total => 1, :failed => 0, :errors => 1, :pending => 0}
32
32
  end
33
33
 
34
- it 'should count the number of specs skipped' do
35
- TestOutputParser::Framework::TestUnit.count(File.read("spec/fixtures/sample-skipped-test-unit-output.txt")).should == {:total => 1, :assertions => 1, :failed => 0, :errors => 0, :skipped => 1}
34
+ it 'should count the number of specs pending' do
35
+ TestOutputParser::Framework::TestUnit.count(File.read("spec/fixtures/sample-pending-test-unit-output.txt")).should == {:total => 1, :failed => 0, :errors => 0, :pending => 1}
36
36
  end
37
37
  end
@@ -2,16 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe TestOutputParser do
4
4
  it 'should give the summary of specs for rspec' do
5
- TestOutputParser.count(File.read("spec/fixtures/sample-failed-rspec-output.txt"), :rspec).should == {:total => 1460, :failed => 1, :pending => 3}
5
+ TestOutputParser.count(File.read("spec/fixtures/sample-failed-rspec-output.txt")).should == {:total => 1460, :failed => 1, :pending => 3}
6
6
  end
7
7
 
8
8
  it 'should give the summary of specs for test unit' do
9
- TestOutputParser.count(File.read("spec/fixtures/sample-failed-test-unit-output.txt"), :test_unit).should == {:total => 1, :assertions => 1, :failed => 1, :errors => 0, :skipped => 0}
9
+ TestOutputParser.count(File.read("spec/fixtures/sample-failed-test-unit-output.txt")).should == {:total => 1, :failed => 1, :errors => 0, :pending => 0}
10
10
  end
11
11
 
12
- it 'should raise an error when a valid framework is not specified' do
13
- lambda do
14
- TestOutputParser.count("foo", :bar)
15
- end.should raise_error(ArgumentError)
12
+ it 'should add up the summaries when there are specs for multiple frameworks' do
13
+ TestOutputParser.count(File.read("spec/fixtures/sample-failed-test-unit-output.txt") + File.read("spec/fixtures/sample-failed-rspec-output.txt")).should == {:total => 1461, :failed => 2, :errors => 0, :pending => 3}
16
14
  end
17
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-output-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akshay Karle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-03 00:00:00.000000000 Z
11
+ date: 2014-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,8 +76,8 @@ files:
76
76
  - spec/fixtures/sample-failed-rspec-output.txt
77
77
  - spec/fixtures/sample-failed-test-unit-output.txt
78
78
  - spec/fixtures/sample-junit-output.txt
79
+ - spec/fixtures/sample-pending-test-unit-output.txt
79
80
  - spec/fixtures/sample-rspec-output.txt
80
- - spec/fixtures/sample-skipped-test-unit-output.txt
81
81
  - spec/fixtures/sample-test-unit-output.txt
82
82
  - spec/framework/rspec_spec.rb
83
83
  - spec/framework/test_unit_spec.rb
@@ -113,8 +113,8 @@ test_files:
113
113
  - spec/fixtures/sample-failed-rspec-output.txt
114
114
  - spec/fixtures/sample-failed-test-unit-output.txt
115
115
  - spec/fixtures/sample-junit-output.txt
116
+ - spec/fixtures/sample-pending-test-unit-output.txt
116
117
  - spec/fixtures/sample-rspec-output.txt
117
- - spec/fixtures/sample-skipped-test-unit-output.txt
118
118
  - spec/fixtures/sample-test-unit-output.txt
119
119
  - spec/framework/rspec_spec.rb
120
120
  - spec/framework/test_unit_spec.rb