How to add Tauk to your existing Pyunit tests?

Thejus Krishna
3 min readMay 12, 2022

--

Companies are often forced to redo previously completed work when they try to implement new technologies because new technologies often make legacy code and frameworks obsolete. An innovative company can solve this problem by adopting new tools ready-made for integration with existing code and frameworks. Tauk aims to eliminate unnecessary procedures and not to create new ones. To demonstrate this, let’s look at how Tauk easily integrates with Pyunit tests.

The Usual Question

“Oh, we have already built the test suites, how do we integrate Tauk now?”

Don’t worry at all. Just follow these steps:

  1. Register with Tauk.com
  2. Create a new project and get the project ID
  3. Create a new API token
  4. Add a few lines with the project ID and the API token to your existing code

How to register with Tauk.com?

Navigate to Tauk.com

Click the button Try Tauk for Free.

Fill up your details.

How to create a new project in Tauk?

Once you have signed up, it will take you to a new screen that will look like the one below:

Fill up the details:

Once you create the project, it will create an ID automatically and show you in the next screen:

Here glokelydQ is the project ID. Save the project ID for calling from the script.

How to create an API token?

Click the settings icon on the bottom left corner of the screen:

Click the API Access tab from menu:

Click on the Generate API Token button:

The API will appear at the top for a few seconds, please copy and keep it for scripting.

How to add your existing Pyunit tests?

  1. Install Tauk by running:
pip install tauk

2. Import the project and initialise tauk:

from tauk.tauk_webdriver import Tauk
from tauk.config import TaukConfig
token = “YoursavedAPItoken”projectid = “YoursavedProjectID”Tauk(TaukConfig(api_token = <your_apitoken>, project_id =<your_projectid>))

3. In the beginning of each test method, add a decorator:

@Tauk.observe(custom_test_name=”test_speedtest”)

4. Inside each method, call register_driver:

Tauk.register_driver(self.driver)

I have written a sample speedtest test case with and without Tauk and taken a diff for better understanding:

https://www.diffchecker.com/LOCJOS9T

The same tests run as they had before on the phone but now Tauk has generated a dashboard without any additional work from the engineer:

Edited on June 8th 2022: Tauk has released exciting new features along with some changes in initialisation. The changes are updated here in the code.

--

--