Skip to main content

Introduction to Debugging Tasks in Visual Studio

Debugging Tasks

R
Written by Riku Virtanen
Updated over a year ago

Debugging Tasks in Visual Studio

Frends Tasks and Frends Community Tasks are mostly open source, so you can check the source code of Tasks that you are using in Processes. You can also make modifications to these Tasks and add them as Custom Tasks to your Frends Environment. If you're having issues with Tasks, you can contact Frends Support at support@frends.com. In addition to contacting Frends Support you can debug issues in the Tasks yourself. Let's take a look at how you can debug issues in Tasks using Visual Studio.

Getting the source code from GitHub

Let's say that you are having issues with the Frends.File.Read Task that you want to debug yourself. You can clone the source of the Task using Git. For example, you can clone the source code of the Frends.File package which contains the Frends.File.Read Task using the command below.

git clone https://github.com/FrendsPlatform/Frends.File.git

After cloning the source code, you can open the project from the file Frends.File.sln. Opening this file in Visual Studio will open the whole project.

Running unit tests

It is good practice to run Task unit tests before making any modifications or starting to debug an issue to make sure that the current tests are working. All Tasks' source code should contain unit tests which should work. Some Tasks require a target system for unit tests to work, so you should check the README.md file for any instructions for running unit tests. Most of the Tasks don't require a target system for unit tests, so you should be able to run them straight away after opening the project in Visual Studio.

Back to our Frends.File.Read Task example, after opening the solution in Visual Studio, we should run unit tests to check if they are working. This can easily be done by right-clicking "Frends.File.Tests" in the Solution Explorer and selecting "Run Tests". This will build the solution and run unit tests.

After clicking "Run Tests", the Test Explorer window will open which will show the status of the unit test run. If all tests show green, then you are ready to start debugging your issue or implement changes to the Tasks.

Debugging the issue

The best way to figure out what could be causing an issue in the Task is to replicate the issue in unit tests. If you are able to create a test that would replicate the issue, then it is easier to pinpoint where exactly the issue may occur. After fixing the issue you can also verify that the issue is actually fixed using the same unit test that you used to replicate the issue.

The easiest way to create a new unit test to test some functionality is to copy an existing unit test and modify it to suit the case. If you are able to replicate the issue in Frends, then the same issue should occur in unit tests if you pass the same parameters to the Task method as you passed in Frends. If you cannot replicate the issue in unit tests then that would indicate that the issue is not in the Task itself, but maybe with the Agent that is running the Process or somewhere else outside the Task source code.

Fixing the issue

If you managed to replicate the issue in unit tests and you want to release a fix for the issue, there are three options. The first option is to create a new issue in the Task package repository with details about the issue and how you managed to replicate it in Frends or in source code and then contact support@frends.com with a short description of the issue and a link to the GitHub issue which has all the details. The second option is to fork the repository to your own account, make the change to your own fork, create a Pull Request to the original repository and then contact support@frends.com. These contribution instructions can be found from all repositories (for example Frends.File). The third option is to create a Custom Task to which you copy the source code of the Task and then import that Custom Task to your Frends.

Did this answer your question?