"How to get test run id from a specific release using TFS 2018 API" - selenium

We have a task in our release pipeline that runs Seleniumtests(Visual studio test task). The selenium tests run and we can after the run add an attachment to the testrun manually. We also manage to add an attachment with the api but we don't have a good way to extract the testrunid that is necessary for the upload.
How do we in a good way get the test run id from a release so we can bind the attachment to the right testrun. We only manage to get all test runs with the api, which is alot.
Where we want the attachment to be uploaded with the api

You can see test run id from the test log for a specific release.
So, the simplest way is getting the specific test run id with the REST API from the log.
GET https://{instance}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}/deployPhases/{releaseDeployPhaseId}/tasks/{taskId}/logs?api-version={version}
See Get task log for details.
EDIT Get Task Log v5

I am using the following API to get test results for the release,
GET https://{instance}/{project}/_apis/ResultDetailsByRelease?releaseId={RELEASE.RELEASEID}&releaseEnvId={RELEASE.ENVIRONMENTURID}
The test results included testRun ID or get failed tests only by using filter,
GET https://{instance}/{project}/_apis/ResultDetailsByRelease?releaseId={RELEASE.RELEASEID}&releaseEnvId=RELEASE.ENVIRONMENTURID}&%24filter=Outcome+eq+Failed

Related

How do I get access to the running test information (screenshot pattern params)

I would like to store some information using the beforeEach and afterEach hooks in a fixture like:
- tracking the REST API calls
- browser console information
and would like to store this information next to the screenshots.
Is there a way to get access to the screenshot params and current path and also know if a test had an assert during it's run?
get access to the screenshot params and current path
It is not possible to access this information in beforeEach/afterEach. TestCafe provides an API to obtain screenshot params for reports only.
 
if a test had an assert during it's run
If a test is successful, there is no any logged information. If a test fails, information about errors will be written to reports.

TeamCity filter builds by tags or time period

Is it possible, through the rest API, to request all the builds with a specific tag? Along the same lines, can I get all the builds from a specific time period? For example, request the builds from 7 am to 7 pm of a specific date?
Background, I am trying to automatically pin builds based on a parameter. I had a custom script that used the rest api to pin builds and I used this script in a command line build step. The problem is, TeamCity won't allow you to pin a build that is in progress. So to get around this I am trying to do the following: I have a build step that uses a custom script to tag a build, then the idea is that I will have a script that I will run every night or so that grabs all the tagged builds, or builds from a specific time period and pin them.
Any other ideas are welcome as well.
Please do a request to:
https://{yourdomain}/app/rest/builds?locator=tag:your-tag
That's it.
From the rest API documentation: https://confluence.jetbrains.com/display/TCD10/REST+API#RESTAPI-BuildRequests
you can use the ?locator=tag:<tagName> tag to get all the builds with a specific tag name.

TFS Link testresult to Task

I have the next structure:
Bug
Dev task
Test Result with the failed test case
Tested by
For retest the bug I have created a RETEST task and link it to the bug. When I rerun the testcase I would like to add the passed test result to the RETEST task. How can I do? Or what is the best workflow?
You don't need to create a retest task for this case.
You could directly customize a workflow using States and Reasons for the Bug work item. Such as adding a state "Ready to Retest" for a Bug. And then assign this work item to the tester or tester group. Suggest you to use the Process Editor, available with the download of TFS Power Tools. The Process Template Editor provides a graphical user interface for customizing work items (field, workflow and the form) and process templates.
More ways for customize the workflow for a process please refer the tutorial from MSDN:
Customize the workflow for a process
Add or modify a work item type
Then you just need to directly link test result to the bug workitem. And in a Bug work item, you can click the HISTORY--ALL CAHNGES to track the history and process.

MSBuild email alert to list failed tests

I'm using TFS, MSBuild and MSTest for automated build and test solution. When some unit tests fail; build partially succeeds and I get email just giving the error information.
Is there any way that I can customize the e-mail content? I want the failed test names and fail reason listed in the mail. Even the test result file as an attachment(1 MB) would do.
Thanks
There is a Jenkins plugin called "Email-ext plugin" link maybe that could help you. However, (I assume) you might need some kind of your own custom template to do what you want.
Example
You can attach a HTML page to your email, likewise you can customize as you want:
stackoverflow question

Script to send email notification in Teamcity

I have a requirement to send email to particular group when Teamcity's build goes green and red.
Does anyone has any idea about it ?
It is possible to configure user group and setup email notifications for this group inside TeamCity.
There are a few TeamCity plugins that you can leverage out of the box but the buildstatusnotifier
looks the most promising. You can also setup a job that gets triggerred upon completion of every build for the project you are tracking. This build will do the following:
Make a call for last status of the build project. See TeamCity REST documentation here for context. Replace "insert-base-url-here" with your teamcity base url & "btXXX" with your build id.
http://{insert-base-url-here}/app/rest/builds/buildType:(id:btXXX)/statusIcon
Save the result of this call in a DB or in a txt file
For every subsequent call, check to see if the new value is the same as the previous; if they are do not send an email. If the values do not match then proceed to step four
Send an email to the recipient/distribution list informing them of a change of status in the build status.
My personal preference will be to do all of these in an nant script but those are the steps to take.
You can also look at the Build-status tool (build-status.appspot.com) which can be setup and displayed in a highly visible place that your team will not miss should it turn red.