1
votes

I'm using the Azure DevOps .NET SDK (v16.530.0-preview) and when I try to create a test run using CreateTestRunAsync (in TestManagementHttpClient) and use the RunCreateModel object as a parameter, it looks like the RunCreateModel's State property is read-only. The docs also confirm this.

TestApi.RunCreateModel run = new TestApi.RunCreateModel
{
     Name = testRun.Name
     //State = testRun.State (is read-only)
};

https://docs.microsoft.com/en-us/dotnet/api/microsoft.teamfoundation.testmanagement.webapi.runcreatemodel.state?view=azure-devops-dotnet-preview#Microsoft_TeamFoundation_TestManagement_WebApi_RunCreateModel_State

But the weirdness is that when creating the run, the UI shows In Progress then it shows the test run running for {x hours, minutes, sec}.

Is there a way I can avoid this and set the state as NotStarted?

1

1 Answers

1
votes

You can define the state in the constructor:

var testRun = new RunCreateModel(name: "API Test Run", state: "NotStarted");
var results = testApi.CreateTestAsync(testRun, "Project").Result;

I succeeded to create a test run with "Not Started" state with the above code.