Don’t get me wrong. baangt is amazing. There is the test data generator, the recorder/importer for WEB-Testcases and the endless possibilities of assertions and other useful tools to make test automation a breeze. Or at least as simple as it can get. But still sometimes especially in really large autotmation projects we find ourselves in a situation where this is not enough. We need to extend test functionality in one way or another.

As baangt is free and open source, there’s no motivation to make this process tedious. On the contrary! By providing good documentation baangt helps also in those situations. Everybody claims that. How can we be sure? How can you be sure? For instance by looking at realistic examples, that go beyond “Hello World”!

More than “Hello world!”

If you are not a python developer and don’t even know, what that is: This article is unfortunately not for you. You may either need to find a python developer or find other ways to extend test functionality. You can (and probably should!) download standard baangt to see, how much you can achieve without having to extend test functionality. For everybody else: Welcome!

First step to expand test functionality: Download the repository

Head over to the Git repository at our gogs server and clone the repository. You can either do that with your favorite IDE or from command line using “git clone https://gogs.earthsquad.global/athos/baangt-subclassingDemo”.

Painless introduction to the repository

README.MD gives some details about the contents of the repository. Check it out to see a short description of all included files and how to run the examples.

Where the music plays when it comes to extend test functionality:

There are two major files involved in this. The first one is in folder examples the file globals.json. Here we tell baangt to not use it’s own TestStepMaster implementation but look for a different class. See the following screenshot:

Extend Test functionality using subclassing

Even though TestStepMaster is one of THE centerpieces of baangt functionality you shall not be scared to implement your own enhancements of the test functionality. At least not if you need to. Let’s take a look, how myTestCaseSequence influences the standard behavior.

Enhance test functionality - the code

In myTestCaseSequence.py we reference to the standard TestCaseSequenceMaster. Python enables us to just overwrite the method, that we need! In the current case we were not happy with logging and simply implement an additional log output. Everything else works without modification. The super().execute() will run all standard baangt functionality. You don’t need to do anything more! Of course you can use the full extend of python functionality here. Import new packages, write functions or classes. Your requirements and your skills are the limit.

Other classes to extend test functionality

Of course TestCaseSequenceMaster is not the only class that you can use. Very popular is for instance TestStepMaster. Often it’s tedious to deal with specific recurring kwirks of a certain application or framework. Even though baangt can handle for instance most of angular toasts out of the box it might be faster and easier for you to develop your own command “handleToasts” and implement there any logic, you wish to interact with Toasts on the webpage. No need to understand the rest of the code in depth – just implement your functionality as needed and you’re good to go!

Another class is the browser handling. This one is not subclassed very often. baangt supports Firefox, Chrome, Edge, Safari out of the box. Now what if your heart beats for the Opera browser? Easy! You can simply overwrite a single method in baangt browser handling and enjoy testing on opera.

Get help!

You don’t have to do it all alone. If you get stuck along the way or want to run some ideas you have about how you’d like to extend test functionality in baangt, get in contact – check out the social media channels in the footer or leave a comment.