Unable to link unit test to test case - login error in visual studio
In visual studio, it is possible to link unit tests (working with MSTEST V1) to test cases in Azure Devops so that test results of unit tests, executed during a build, can be reported directly to test cases in Azure Devops.
The idea is that you can "right click" a unit test in the unit test explorer in visual studio and then associate a test case in the context menu.
Sometimes however, it fails on the error below:
It suggests that you need to be logged in into Team Services, Team foundation server, VSTS, Azure Devops,... But it does not indicate where you need to do so. I tried figuring out and it took me a while. I just list my different ideas so that you do not have to go through them (again)
- At first, I tried connecting to Azure Devops from the team explorer, just by selecting the team project. this did not work
- Then I opened MicroSoft Test Manager, the deprecated testing tool, and connected here also to Azure Devops. This did also not resolve my issue.
- Then I went looking in the settings of visual studio, looking for a clue...
After a while, I figured out that when connecting to a team project in the connection manager in visual studio, it is also possible to select a repo (instead of a team project) and connect to it. The difference seems to be futile, but it makes all the difference!
After I selected the correct git repo (the one that contained the unit tests), there was no more error and the issue seemed to be solved.
I was then able to specify the ID of the test case and the link between the unit test in code and the test case in Azure Devops was created.
It thus seems that visual studio really needs this "security context" in order to function correctly here... Not sure why though!
I hope that it saves you some time when you run into this issue!