Skip to content

rwb.lint User Guide

boakley edited this page Jul 13, 2012 · 2 revisions

Note: this tool is considerably less polished than any of the other tools. In fact I'm not even sure it works right now. It's still mostly in the idea phase of development.

Description

rwb.lint is a command line tool for performing static analysis on test suites. The tool takes one or more suite names on the command line, parses each suite, then passes each suite, test and keyword through a series of rules.

Rule definitions

At present, rules are defined in the file rules.py, inside the rwb.lint module. Each rule is a subclass that inherits from rwb.lint.rules.TestSuiteRule, rwb.lint.rules.TestSuiteRule, rwb.lint.rules.TestCaseRule and/or rwb.lint.rules.KeywordRule.

Each rule must define the call method. In that method it should do whatever checks it needs to do, then call self.warn with the object that generated the warning, and the string representation of the warning. For example, a rule to check that there are no tags with spaces might look like the following:

class TagNameNoSpace(TestCaseRule):
    '''Verify that tag names don't include spaces'''
    def __call__(self, testcase):
        if testcase.tags is not None and testcase.tags.value is not None:
            for tag in testcase.tags.value:
                if " " in tag.strip():
                    self.warn(testcase, "tag should not contain spaces: '%s'" % (tag,))

Eventually it will be possible to define rules outside of the module, I just haven't had time to implement that yet. This is still very much a work-in-progress.

Clone this wiki locally