In the previous article, I have told how to run GitHub Actions locally. Today, I want to tell you how to log failed tests on GitHub. All of you faced when your pipeline fell due to the unit tests. Usually, you could see logs in error reports at GitHub in the Actions tab. In this report, you could see that some kind of test failed.
If you have hundreds or even thousands of unit tests, then it's become a problem. It requires a jump to the tests and checks for errors. I run failed test and you can see the result:
As shown in the screenshot, you can see only the assembly title in which an error. However, you don't see which test.
However, I'll show how to collect logs on GitHub when the tests fail.
First of all, let's install the package:
dotnet add package GitHubActionsTestLogger
In the following step, you should put in your action yml file add this parameter:
--logger GitHubActions
And you'll get a different error report, something like that:
You no longer need to seek in which place you got an error. Instead, you'll see all the information required on GitHub.
You also can configure annotations:
--logger "GitHubActions;annotations.titleFormat=Your UnitTests;annotations.messageFormat=Your test fail"
For more details, you can see official REPO
Happy coding!
Top comments (0)