A
aidy
Sorry to bother you again
I have two test classes
<snip>
class TEST_1
def initialize
$log.xml_logger(self.class, 'pass')
end
end
<snip>
<snip>
class TEST_2
def initialize
$log.xml_logger(self.class, 'fail')
end
end
<snip>
I also have a logging class
<snip>
class Logging
def initialize
@doc = Document.new
xmldecl = XMLDecl.default
@doc.add(xmldecl)
end
def xml_logger(test_name, vp_text)
test_result = @doc.add_element 'testresults'
test = test_result.add_element 'test'
test.attributes["id"] = test_name
if vp_text.upcase == 'PASS' then
test_status= test.add_element 'pass'
test_status.text = 'PASS'
else
fail = test.add_element 'fail'
fail.text = 'FAIL!'
end
end
def xml_to_file
@doc.write($stdout, 1)
@doc.write(File.open("C:/test_results.xml","w"))
end
end
<snip>
I have a file that starts the logger, runs the tests and then closes
the log
$log = Logging.new
TEST_1.new
TEST_2.new
$log.xml_to_file
Now, what I am currently getting is this
<testresults>
<test id='TEST_1'>
<pass>PASS</pass>
</test>
</testresults>
and what I actually want is this
<testresults>
<test id='TEST_1'>
<pass>PASS</pass>
</test>
<test id='TEST_2'>
<fail>FAIL</fail>
</test>
</testresults>
what I really want to do, is keep adding to the xml file until, I
invoke the #xml_to_file method.
Should I be creating a Document.new every time I log?
Cheers
Aidy
I have two test classes
<snip>
class TEST_1
def initialize
$log.xml_logger(self.class, 'pass')
end
end
<snip>
<snip>
class TEST_2
def initialize
$log.xml_logger(self.class, 'fail')
end
end
<snip>
I also have a logging class
<snip>
class Logging
def initialize
@doc = Document.new
xmldecl = XMLDecl.default
@doc.add(xmldecl)
end
def xml_logger(test_name, vp_text)
test_result = @doc.add_element 'testresults'
test = test_result.add_element 'test'
test.attributes["id"] = test_name
if vp_text.upcase == 'PASS' then
test_status= test.add_element 'pass'
test_status.text = 'PASS'
else
fail = test.add_element 'fail'
fail.text = 'FAIL!'
end
end
def xml_to_file
@doc.write($stdout, 1)
@doc.write(File.open("C:/test_results.xml","w"))
end
end
<snip>
I have a file that starts the logger, runs the tests and then closes
the log
$log = Logging.new
TEST_1.new
TEST_2.new
$log.xml_to_file
Now, what I am currently getting is this
<testresults>
<test id='TEST_1'>
<pass>PASS</pass>
</test>
</testresults>
and what I actually want is this
<testresults>
<test id='TEST_1'>
<pass>PASS</pass>
</test>
<test id='TEST_2'>
<fail>FAIL</fail>
</test>
</testresults>
what I really want to do, is keep adding to the xml file until, I
invoke the #xml_to_file method.
Should I be creating a Document.new every time I log?
Cheers
Aidy