-
Notifications
You must be signed in to change notification settings - Fork 48
The TestRule class
boakley edited this page Nov 30, 2014
·
1 revision
The TestRule class is an abstract class that should be inherited by all rules that operate on a Testcase. When the rule is applied (ie: the apply
method is called), an instance of the Testcase will be passed as a parameter. The class has an attribute named severity
which defines the severity of the rule. The default severity is WARNING
but may be overridden in the concrete class.
Every class that inherits from this class must define a method named apply
. This method must take exactly one parameter, a Testcase object.
For example, here is a testcase rule that that requires a test to have documentation:
from rflint.common import TestRule, ERROR
from rflint.parser import SettingTable
class RequireTestDocumentation(TestRule):
'''Verify that a test suite has documentation'''
severity=ERROR
def apply(self, testcase):
for setting in testcase.settings:
if setting[1].lower() == "[documentation]" and len(setting) > 2:
return
# set the line number to the line immedately after the testcase name
self.report(testcase, "No testcase documentation", testcase.linenumber+1)