What is a baangt-plugin

Simply speaking, one baangt-plugin correspond to one class, and the methods in the class correspond to the implements in the plugin.

how to make a baangt-plugin

first of all , we need to create a implement class, like this:

import baangt

from baangt.base.Timing.Timing import Timing

class TimingHookImpl:

    def timing_init(self):
        return Timing()

    def timing_takeTime(self, timingObject, timingName, forceNew=False):
        return timingObject.takeTime(timingName, forceNew)

    def timing_addAttribute(self, timingObject, attribute, value, timingSection=None):
        return timingObject.addAttribute(attribute, value, timingSection)

    def timing_takeTimeSumOutput(self, timingObject):
        return timingObject.takeTimeSumOutput()

    def timing_returnTime(self, timingObject):
        return timingObject.returnTime()

    def timing_returnTimeSegment(self, timingObject, segment):
        return timingObject.returnTimeSegment(segment)

    def timing_resetTime(self, timingObject):
        return timingObject.resetTime()

and then register this implement class in /baangt/_*init_*.py:

from baangt.base.Timing.hookImpls import TimingHookImpl


how the baangt-plugin work

for example, after transfer TestRun to a plugin, we can replace the code:

from xxx import TestRun


from xxx import plugin_manager

this replacement does not change anything of the result of programme’s execution.

how to replace the existing plugin by your own one

for example, if you want to replace the default TestRun plugin,

you can easily change the implement of TestRun by just unregister the default plugin and register your own one:


notice that if you don’t unregister the old one, two same implements (with same function name) in two plugins may both execute if you call the function:


the order of the execution follows the FILO (first-in-last-out) rule.

Author: Yuyi Shao