Class: SimpleJUnit::TestSuite

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_junit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ TestSuite

Returns a new instance of TestSuite.



44
45
46
47
48
# File 'lib/simple_junit.rb', line 44

def initialize(name)
  @name = name
  @timestamp = Time.now()
  @testcases = []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



41
42
43
# File 'lib/simple_junit.rb', line 41

def name
  @name
end

#testcasesObject

Returns the value of attribute testcases.



42
43
44
# File 'lib/simple_junit.rb', line 42

def testcases
  @testcases
end

Instance Method Details

#add_testcase(testcase) ⇒ Object



50
51
52
53
54
# File 'lib/simple_junit.rb', line 50

def add_testcase(testcase)
  unless @testcases.include? testcase
    @testcases << testcase
  end
end

#create_testcase(name, desc = nil) ⇒ Object



56
57
58
59
# File 'lib/simple_junit.rb', line 56

def create_testcase(name, desc=nil)
  @testcases << TestCase.new(name, desc)
  @testcases.last
end

#to_sObject



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/simple_junit.rb', line 61

def to_s
  num_testcase = @testcases.count
  num_failures = (@testcases.select {|tc| tc.failed?}).count

  return <<-EOTS
  <testsuite name="#{@name}" errors="0" tests="#{num_testcase}" failures="#{num_failures}" time="0" timestamp="#{@timestamp.iso8601}">
<properties/>
#{(@testcases.collect {|tc| tc.to_s}).join}
  </testsuite>
EOTS
end