Revision: c732ef3e1830
Author: Jussi Malinen
Date: Wed Mar 7 04:23:12 2012
Log: added built-in keyword for setting test documentation
http://code.google.com/p/robotframework/source/detail?r=c732ef3e1830
Added:
/atest/robot/standard_libraries/builtin/set_documentation.txt
/atest/testdata/standard_libraries/builtin/set_documentation.txt
Modified:
/src/robot/libraries/BuiltIn.py
/src/robot/output/xmllogger.py
=======================================
--- /dev/null
+++ /atest/robot/standard_libraries/builtin/set_documentation.txt Wed Mar
7 04:23:12 2012
@@ -0,0 +1,11 @@
+*** Settings ***
+Suite Setup Run Tests ${EMPTY}
standard_libraries/builtin/set_documentation.txt
+Force Tags regression jybot pybot
+Resource atest_resource.txt
+
+*** Test Cases ***
+Set test documentation
+ Check Test Doc ${TESTNAME} This has been set!\nTo several lines.
+
+Replace test documentation
+ Check Test Doc ${TESTNAME} New doc
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/builtin/set_documentation.txt Wed
Mar 7 04:23:12 2012
@@ -0,0 +1,7 @@
+*** Test Cases ***
+Set test documentation
+ Set test documentation This has been set!\nTo several lines.
+
+Replace test documentation
+ [Documentation] This will be replaced
+ Set test documentation New doc
=======================================
--- /src/robot/libraries/BuiltIn.py Tue Mar 6 00:46:30 2012
+++ /src/robot/libraries/BuiltIn.py Wed Mar 7 04:23:12 2012
@@ -1805,6 +1805,24 @@
test.message = message
self.log('Set test message to:\n%s' % message)
+ def set_test_documentation(self, doc):
+ """Sets documentation for for the current test.
+
+ The current documentation is available from built-in variable
+ ${TEST DOCUMENTATION}. This keyword can not be used in suite
+ setup or suite teardown.
+
+ New in Robot Framework 2.7.
+ """
+ if not isinstance(doc, unicode):
+ doc = utils.unic(doc)
+ test = self._namespace.test
+ if not test:
+ raise RuntimeError("'Set Test Documentation' keyword cannot be
used in "
+ "suite setup or teardown")
+ test.doc = doc
+ self.log('Set test documentation to:\n%s' % doc)
+
def set_tags(self, *tags):
"""Adds given `tags` for the current test or all tests in a suite.
=======================================
--- /src/robot/output/xmllogger.py Tue Mar 6 00:46:30 2012
+++ /src/robot/output/xmllogger.py Wed Mar 7 04:23:12 2012
@@ -75,9 +75,9 @@
def start_test(self, test):
self._writer.start('test', {'id': test.id, 'name': test.name,
'timeout': test.timeout})
- self._writer.element('doc', test.doc)
def end_test(self, test):
+ self._writer.element('doc', test.doc)
self._write_list('tags', 'tag', test.tags)
self._write_status(test, test.message,
{'critical': 'yes' if test.critical else 'no'})