junit_report_generator 1.0.0 → 1.0.1

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: ac539b6d06cc043c568be60e360c3380e217ea0b
4
- data.tar.gz: 82dff12242140aa88ad19cc01003c7122f57c24d
3
+ metadata.gz: 8f99b21d446eea7965a83681dc161762721be86c
4
+ data.tar.gz: 468c20d28f459868051a3a4d48c07aaf28cba44d
5
5
  SHA512:
6
- metadata.gz: 0ad2f7b2038c60a402d982acff6f52d46c4887cab9291d4ad3b78e1d9215b1cdf456b27b759ae9ece022198ba6e548fd452f3b0b2c1ec303b15ec7a48821bcd3
7
- data.tar.gz: 8e1303686bc794483617c409f9ad02a777d39bb4e05b7a7439066fe6861af1614b7dc3b4fc8c9be456ee7c0cd1d4fb6a2ad2afecb22cdbb279a07b5df193676b
6
+ metadata.gz: 6ef0da4d833b1d4fed1e0ee084c96ed5d04ef5e3c9c20e91cc754e506ad559a1fd4040dabedbd6d0062e3c7c694d9ca8207e6c69a470dd941625570931eb95f7
7
+ data.tar.gz: 3970ce7ad96908d3198150f1d45aa4dce9b1079c007dbc806b09f9fb089a7c517773fc5da7a3f7416beffb4377a026b28bc82a36d59fcd5af7a1816820f50b8e
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # JunitReportGenerator
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/junit_report_generator.svg)](http://badge.fury.io/rb/junit_report_generator)
3
4
  [![Build Status](https://travis-ci.org/thyrlian/JunitReportGenerator.svg?branch=master)](https://travis-ci.org/thyrlian/JunitReportGenerator)
4
5
  [![Code Climate](https://codeclimate.com/github/thyrlian/JunitReportGenerator/badges/gpa.svg)](https://codeclimate.com/github/thyrlian/JunitReportGenerator)
5
6
  [![Test Coverage](https://codeclimate.com/github/thyrlian/JunitReportGenerator/badges/coverage.svg)](https://codeclimate.com/github/thyrlian/JunitReportGenerator/coverage)
@@ -48,6 +49,9 @@ TestCase.create('test').add(Error.create) # Error
48
49
  TestCase.create('test').add(Skipped.create) # Skipped
49
50
  ```
50
51
 
52
+ ## Utilization
53
+ Jenkins -> Job -> Configure -> Post-build Actions -> Add post-build action -> Publish JUnit test result report -> Test report XMLs
54
+
51
55
  ## Notes
52
56
  The statistics attributes in testsuite(s) are not really used by Jenkins (they are optional), in fact, Jenkins is doing the math by itself via counting the numbers from each testcase.
53
57
  ```xml
@@ -1,13 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
- $: << File.expand_path('../lib', __FILE__)
4
- require 'junit_report_generator'
5
-
6
3
  Gem::Specification.new do |s|
7
4
  s.name = 'junit_report_generator'
8
- s.version = JunitReportGenerator::VERSION
5
+ s.version = '1.0.1'
9
6
  s.license = 'MIT'
10
- s.date = '2015-08-11'
7
+ s.date = '2015-08-13'
11
8
  s.summary = 'Generating JUnit test report easily from any source.'
12
9
  s.description = 'Generating JUnit test result report (xml) from any format of data by super easy and flexible syntax. Most of the CIs (Continuous Integration) can aggregate JUnit style reports with zero effort.'
13
10
  s.authors = ['Jing Li']
@@ -15,6 +12,7 @@ Gem::Specification.new do |s|
15
12
  s.files = `git ls-files`.split("\n")
16
13
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
14
  s.homepage = 'https://github.com/thyrlian/JunitReportGenerator'
15
+ s.required_ruby_version = '~> 2.0'
18
16
  s.add_dependency 'nokogiri', '~> 1.6'
19
17
  s.add_development_dependency 'rake', '~> 10.4'
20
18
  s.add_development_dependency 'minitest', '~> 5.7'
@@ -12,6 +12,7 @@ module JunitReportGenerator
12
12
  end
13
13
 
14
14
  def update_attributes(*attrs)
15
+ initialize_attributes_if_not_yet
15
16
  attrs.each do |attr|
16
17
  attr = attr.to_sym
17
18
  instance_variable_get(:@attributes)[attr] = instance_variable_get("@#{attr.id2name}")
@@ -19,12 +20,22 @@ module JunitReportGenerator
19
20
  end
20
21
 
21
22
  def method_missing(method, *args)
23
+ initialize_attributes_if_not_yet
22
24
  instance_variable_get(:@attributes)[method] = args.first
23
25
  self.class.send(:define_method, method) do |value|
26
+ initialize_attributes_if_not_yet
24
27
  instance_variable_get(:@attributes)[method] = value
25
28
  self
26
29
  end
27
30
  self
28
31
  end
32
+
33
+ def initialize_attributes_if_not_yet
34
+ unless instance_variable_get(:@attributes)
35
+ instance_variable_set(:@attributes, {})
36
+ end
37
+ end
38
+
39
+ private :initialize_attributes_if_not_yet
29
40
  end
30
41
  end
@@ -7,7 +7,9 @@ module JunitReportGenerator
7
7
 
8
8
  class << self
9
9
  def create(*args)
10
- new(*args)
10
+ obj = new(*args)
11
+ obj.instance_variable_set(:@attributes, {}) unless obj.attributes
12
+ obj
11
13
  end
12
14
 
13
15
  def include_containable
@@ -1,5 +1 @@
1
- Dir.glob(File.expand_path(File.dirname(__FILE__)) + '/junit_report_generator/**/*.rb').each { |file| require file }
2
-
3
- module JunitReportGenerator
4
- VERSION = '1.0.0'
5
- end
1
+ Dir.glob(File.expand_path(File.dirname(__FILE__)) + '/junit_report_generator/**/*.rb').each { |file| require file }
data/test/test_element.rb CHANGED
@@ -11,6 +11,7 @@ class TestElement < Minitest::Test
11
11
  def initialize(name, value)
12
12
  @name = name
13
13
  @value = value
14
+ assemble_attributes(:name, :value)
14
15
  end
15
16
  end
16
17
  end
@@ -46,4 +47,14 @@ class TestElement < Minitest::Test
46
47
  @klass.xml_tag_name
47
48
  end
48
49
  end
50
+
51
+ def test_attributes_is_initialized
52
+ obj = @klass.create
53
+ assert_equal({}, obj.attributes)
54
+ end
55
+
56
+ def test_attributes_is_not_reset
57
+ obj = @klass_with_constructor.create('AwesomeTest', 23)
58
+ assert_equal({:name => 'AwesomeTest', :value => 23}, obj.attributes)
59
+ end
49
60
  end
@@ -2,7 +2,7 @@ require_relative 'helper'
2
2
 
3
3
  class TestElementary < Minitest::Test
4
4
  def setup
5
- @klass = Class.new do
5
+ @klass_with_dflt_attrs = Class.new do
6
6
  include Elementary
7
7
 
8
8
  def initialize(name, value)
@@ -17,27 +17,51 @@ class TestElementary < Minitest::Test
17
17
  end
18
18
  end
19
19
 
20
- @object = @klass.new('foobar', 88)
20
+ @klass_without_anything = Class.new do
21
+ include Elementary
22
+ end
23
+
24
+ @obj_with_dflt_attrs = @klass_with_dflt_attrs.new('foobar', 88)
25
+ @obj_without_dflt_attrs = @klass_without_anything.new
21
26
  end
22
27
 
23
28
  def test_assemble_attributes
24
- assert_equal({:name => 'foobar', :value => 88}, @object.attributes)
29
+ assert_equal({:name => 'foobar', :value => 88}, @obj_with_dflt_attrs.attributes)
25
30
  end
26
31
 
27
32
  def test_update_attributes
28
- @object.change(1024)
29
- assert_equal({:name => 'foobar', :value => 1024}, @object.attributes)
33
+ @obj_with_dflt_attrs.change(1024)
34
+ assert_equal({:name => 'foobar', :value => 1024}, @obj_with_dflt_attrs.attributes)
30
35
  end
31
36
 
32
37
  def test_method_missing_should_add_optional_attribute
33
- @object.status('Unknown')
34
- assert_equal({:name => 'foobar', :value => 88, :status => 'Unknown'}, @object.attributes)
38
+ @obj_with_dflt_attrs.status('Unknown')
39
+ assert_equal({:name => 'foobar', :value => 88, :status => 'Unknown'}, @obj_with_dflt_attrs.attributes)
35
40
  end
36
41
 
37
42
  def test_method_missing_should_cache_optional_attribute_to_method
38
- assert(!@klass.instance_methods.include?(:status))
39
- @object.status('Unknown')
40
- assert(@klass.instance_methods.include?(:status))
41
- assert_equal({:name => 'foobar', :value => 88, :status => 'Unknown'}, @object.attributes)
43
+ assert(!@klass_with_dflt_attrs.instance_methods.include?(:status))
44
+ @obj_with_dflt_attrs.status('Unknown')
45
+ assert(@klass_with_dflt_attrs.instance_methods.include?(:status))
46
+ assert(({:name => 'foobar', :value => 88, :status => 'Unknown'}.to_a - @obj_with_dflt_attrs.attributes.to_a).empty?)
47
+ end
48
+
49
+ def test_attributes_is_nil_before_initialization
50
+ assert_nil(@obj_without_dflt_attrs.attributes)
51
+ end
52
+
53
+ def test_attributes_is_set_after_initialization
54
+ @obj_without_dflt_attrs.send(:initialize_attributes_if_not_yet)
55
+ assert_equal({}, @obj_without_dflt_attrs.attributes)
56
+ end
57
+
58
+ def test_attributes_is_assured_initialized_in_update_attributes
59
+ @obj_without_dflt_attrs.update_attributes(:status)
60
+ assert_equal({:status => nil}, @obj_without_dflt_attrs.attributes)
61
+ end
62
+
63
+ def test_attributes_is_assured_initialized_in_method_missing
64
+ @obj_without_dflt_attrs.send(:method_missing, :status, 'Good')
65
+ assert_equal({:status => 'Good'}, @obj_without_dflt_attrs.attributes)
42
66
  end
43
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: junit_report_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jing Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-11 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -123,9 +123,9 @@ require_paths:
123
123
  - lib
124
124
  required_ruby_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - '>='
126
+ - - ~>
127
127
  - !ruby/object:Gem::Version
128
- version: '0'
128
+ version: '2.0'
129
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - '>='