Version:

Tester Guide

/ binnacle / devel / plugins/

Plugins

Command plugins

Any commands available in system PATH then those commands can be executed using Binnacle. While working with multi node, make sure to install/deploy the additional commands to respective node.

For example, below python script(json-compare.py) compares the two json files and validates only a few fields.

#!/usr/bin/env python
# file: json-compare

import json
import sys

file1 = json.load(open(sys.argv[1]))
file2 = json.load(open(sys.argv[2]))

if file1["name"] != file2["name"]:
    print("name field doesn't match", file=sys.stderr)
    print("Expected: %s Actual: %s" % (file1["name"], file2["name"]))
    sys.exit(1)

if file1["value"] != file2["value"]:
    print("value field doesn't match", file=sys.stderr)
    print("Expected: %s Actual: %s" % (file1["value"], file2["value"]))
    sys.exit(1)
$ chmod +x json-compare
$ sudo cp ./json-compare /usr/local/bin/

Now use that command in your test file

TEST "json-compare sample.json /uploads/input.json"

Writing command plugin is not limited to Python, it can be using any Programming language of your choice. Make sure that file is executable and available in PATH.

Bonus: Below Python script helps to write multiple functions inside same Python file, instead of creating one file per plugin.

def test1():
    # TODO: implement this
    pass

def test2():
    # TODO: implement this
    pass

if __name__ == "__main__":
    # TODO: Validate number of arguments
    func_name = sys.argv[1]
    func_args = sys.argv[2:]
    func = globals().get(func_name, None)
    if func is not None:
        func(*func_args)
   else:
      # TODO: Error message and exit non zero
      pass

Use the above script as,

TEST "python3 myscript.py test1 args.."
TEST "python3 myscript.py test2 args.."

Keywords Plugins

As of now, only Ruby programming is supported for adding new keyword to Binnacle. Documentation to add new keywords is coming soon.

Remote plugins

Coming soon

© 2021 Kadalu Software Private Limited. All Rights Reserved.