I'm trying to launch an automated Test from a C# code.
This is a snippet of my code:
string organizationName = "...";
string projectName = "...";
int planId = ...;
string definitionName = "...";
int definitionId = ...;
string releaseName = "...";
int[] pointIds = new int[] { ... };
Uri organizationUrl = await VssConnectionHelper.GetOrganizationUrlAsync(organizationName);
VssConnection connection = new VssConnection(organizationUrl, new VssClientCredentials());
BuildHttpClient buildClnt = connection.GetClient<BuildHttpClient>();
Build build = await buildClnt.GetLatestBuildAsync(projectName, definitionName);
Microsoft.TeamFoundation.TestManagement.WebApi.ShallowReference testPlanRef = new Microsoft.TeamFoundation.TestManagement.WebApi.ShallowReference(planId.ToString());
ReleaseHttpClient releaseClnt = connection.GetClient<ReleaseHttpClient>();
ReleaseStartMetadata releaseStartMetadata = new ReleaseStartMetadata()
{
DefinitionId = definitionId
};
Release release = await releaseClnt.CreateReleaseAsync(releaseStartMetadata, projectName);
RunCreateModel testRunModel = new RunCreateModel(
name : releaseName,
pointIds : pointIds,
plan : testPlanRef,
buildId : build.Id,
isAutomated : true,
releaseUri : release.Url
);
TestManagementHttpClient testMngmnt = connection.GetClient<TestManagementHttpClient>();
TestRun testRun = await testMngmnt.CreateTestRunAsync(testRunModel, projectName);
When I run this code I receive an exception "Both release id and release environment id must be specified" but I haven't found a way to specify them correctly. If I don't specify releaseUri in RunCreateModel the TestRun is not associated to the Release; I don't know if the value I set is right.
May someone please tell me how I can do that?