froglogic / All / Squish tip of the week: Enable Verbose Test Result Logging

Squish tip of the week: Enable Verbose Test Result Logging

Need more detailed information in your test results?

Nightly or scheduled test runs results often provide valuable quick-read information.

What about times when verbose logging, or a Test Audit Log, may prove valuable?

The following example illustrates how to create a fully-customizable Test Audit Log using Squish. Each action is modified to include a log message and description when executed. Simply calling the enableVerboseLogging() function from the main() test case activates verbose logging.

Functionality available for all Squish-supported scripting languages and application toolkits. Example in Python using Java Swing application.


def main():
# activate item
def alterActivateItem(activateItemFunction):
    def wrappedFunction(menuObject,
                       logText="activateItem() called"):
       test.log(logText, 'Activated item %s' % objectMap.
    return wrappedFunction

# click button
def alterClickButton(clickButtonFunction):
    def wrappedFunction(button, logText="clickButton()"
                        + " called"):
        test.log(logText, 'Clicked %s' % objectMap.
    return wrappedFunction

# mouse click
def alterMouseClick(mouseClickFunction):
    def wrappedFunction(objectToClick, posX=None,
                   posY=None, buttonClicks=None,
                   buttonState=None, buttonPressed=None,
                   logText="mouseClick() called"):
        test.log(logText,'Mouse clicked %s' % objectMap.
    return wrappedFunction

# type
def alterTypeFunction(typeFunction):
    def wrappedFunction(objectToTypeIn, stringInput,
                        logText="type() called"):
        test.log(logText, 'Typed %(text)s in %(field)s'
                 % {"text":stringInput,
        typeFunction(objectToTypeIn, stringInput)
    return wrappedFunction

# call Squish function modifications
def enableVerboseLogging():
    test.log("Verbose logging enabled")

    global activateItem
    activateItem = alterActivateItem(activateItem)

    global clickButton
    clickButton = alterClickButton(clickButton)

    global mouseClick
    mouseClick = alterMouseClick(mouseClick)

    global type
    type = alterTypeFunction(type)

Download suite_AuditLogReport_py example

Leave a Reply

Your email address will not be published. Required fields are marked *

Copy link
Powered by Social Snap