Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support TMS 5.2. #64

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The repository contains new versions of adaptors for dotnet test frameworks.
| 4.5 | 1.1 | 1.1 | 1.1 |
| 4.6 | 1.4 | 1.4 | 1.4 |
| 5.0 | 1.6 | 1.6 | 1.6 |
| 5.2 | 1.7 | 1.7 | 1.7 |

Supported test frameworks :

Expand Down
10 changes: 6 additions & 4 deletions Tms.Adapter.Core/Client/Converter.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using TestIT.ApiClient.Model;
using Tms.Adapter.Core.Models;
using Link = Tms.Adapter.Core.Models.Link;
using LinkType = TestIT.ApiClient.Model.LinkType;
using StepResult = Tms.Adapter.Core.Models.StepResult;

namespace Tms.Adapter.Core.Client;

public static class Converter
{
public static CreateAutoTestRequest ConvertAutoTestDtoToPostModel(TestContainer result, ClassContainer container,
public static AutoTestPostModel ConvertAutoTestDtoToPostModel(TestContainer result, ClassContainer container,
string projectId)
{
return new CreateAutoTestRequest(externalId: result.ExternalId, name: result.DisplayName)
return new AutoTestPostModel(externalId: result.ExternalId, name: result.DisplayName)
{
ExternalId = result.ExternalId,
Links = ConvertLinksToPostModel(result.Links),
Expand All @@ -25,10 +27,10 @@
};
}

public static UpdateAutoTestRequest ConvertAutoTestDtoToPutModel(TestContainer result, ClassContainer container,
public static AutoTestPutModel ConvertAutoTestDtoToPutModel(TestContainer result, ClassContainer container,
string projectId)
{
return new UpdateAutoTestRequest(externalId: result.ExternalId, name: result.DisplayName)
return new AutoTestPutModel(externalId: result.ExternalId, name: result.DisplayName)
{
ExternalId = result.ExternalId,
Links = ConvertLinksToPutModel(result.Links),
Expand All @@ -54,7 +56,7 @@
ConfigurationId = new Guid(configurationId),
Links = ConvertLinksToPostModel(result.ResultLinks),
Message = result.Message,
Traces = result.Trace,

Check warning on line 59 in Tms.Adapter.Core/Client/Converter.cs

View workflow job for this annotation

GitHub Actions / validate (./Tms.Adapter.XUnit)

Possible null reference assignment.
StartedOn = DateTimeOffset.FromUnixTimeMilliseconds(container.Start).UtcDateTime,
CompletedOn = DateTimeOffset.FromUnixTimeMilliseconds(container.Stop).UtcDateTime,
Duration = result.Stop - result.Start,
Expand Down
1 change: 1 addition & 0 deletions Tms.Adapter.Core/Client/ITmsClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using TestIT.ApiClient.Model;
using Tms.Adapter.Core.Models;
using Link = Tms.Adapter.Core.Models.Link;

namespace Tms.Adapter.Core.Client;

Expand Down
7 changes: 4 additions & 3 deletions Tms.Adapter.Core/Client/TmsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using TestIT.ApiClient.Model;
using Tms.Adapter.Core.Configurator;
using Tms.Adapter.Core.Models;
using Link = Tms.Adapter.Core.Models.Link;
using LinkType = TestIT.ApiClient.Model.LinkType;

namespace Tms.Adapter.Core.Client;
Expand Down Expand Up @@ -121,7 +122,7 @@ public async Task LinkAutoTestToWorkItems(string autotestId, IEnumerable<string>
{
try
{
await _autoTests.LinkAutoTestToWorkItemAsync(autotestId, new LinkAutoTestToWorkItemRequest(workItemId ?? string.Empty)).ConfigureAwait(false);
await _autoTests.LinkAutoTestToWorkItemAsync(autotestId, new WorkItemIdModel(workItemId ?? string.Empty)).ConfigureAwait(false);
_logger.LogDebug(
"Link autotest {AutotestId} to workitem {WorkitemId} is successfully",
autotestId,
Expand Down Expand Up @@ -217,12 +218,12 @@ public async Task CreateTestRun()
return;
}

var createTestRunRequestBody = new CreateEmptyRequest
var testRunV2PostShortModel = new TestRunV2PostShortModel
{
ProjectId = new Guid(_settings.ProjectId),
Name = (string.IsNullOrEmpty(_settings.TestRunName) ? null : _settings.TestRunName)!
};
var testRun = await _testRuns.CreateEmptyAsync(createTestRunRequestBody);
var testRun = await _testRuns.CreateEmptyAsync(testRunV2PostShortModel);

_settings.TestRunId = testRun.Id.ToString();

Expand Down
4 changes: 2 additions & 2 deletions Tms.Adapter.Core/Tms.Adapter.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.6.5</Version>
<Version>1.7.0</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
Expand Down Expand Up @@ -48,7 +48,7 @@
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
<PackageReference Include="TestIt.ApiClient" Version="3.0.0" />
<PackageReference Include="TestIt.ApiClient" Version="3.1.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions Tms.Adapter.CoreTests/Client/ConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void ConvertAutoTestDtoToPostModel()
var actual = Converter.ConvertAutoTestDtoToPostModel(testContainer, classContainer, id);

// Assert
Assert.IsInstanceOfType<CreateAutoTestRequest>(actual);
Assert.IsInstanceOfType<AutoTestPostModel>(actual);
Assert.IsNotNull(actual);
}

Expand Down Expand Up @@ -64,7 +64,7 @@ public void ConvertAutoTestDtoToPutModel()
var actual = Converter.ConvertAutoTestDtoToPutModel(testContainer, classContainer, id);

// Assert
Assert.IsInstanceOfType<UpdateAutoTestRequest>(actual);
Assert.IsInstanceOfType<AutoTestPutModel>(actual);
Assert.IsNotNull(actual);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.6.5</Version>
<Version>1.7.0</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion Tms.Adapter.XUnit/Tms.Adapter.XUnit.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.6.5</Version>
<Version>1.7.0</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion Tms.Adapter/Tms.Adapter.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.6.5</Version>
<Version>1.7.0</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
Expand Down
9 changes: 5 additions & 4 deletions TmsRunner/Managers/TmsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using TmsRunner.Entities;
using TmsRunner.Entities.AutoTest;
using TmsRunner.Utils;
using AutoTest = TmsRunner.Entities.AutoTest.AutoTest;

namespace TmsRunner.Managers;

Expand All @@ -19,15 +20,15 @@ public sealed class TmsManager(ILogger<TmsManager> logger,

public async Task<string?> CreateTestRunAsync()
{
var createTestRunRequestBody = new CreateEmptyRequest
var testRunV2PostShortModel = new TestRunV2PostShortModel
{
ProjectId = new Guid(settings.ProjectId ?? string.Empty),
Name = (string.IsNullOrEmpty(settings.TestRunName) ? null : settings.TestRunName)!
};

logger.LogDebug("Creating test run {@TestRun}", createTestRunRequestBody);
logger.LogDebug("Creating test run {@TestRun}", testRunV2PostShortModel);

var testRun = await testRunsApi.CreateEmptyAsync(createTestRunRequestBody).ConfigureAwait(false) ?? throw new Exception($"Could not find project with id: {settings.ProjectId}");
var testRun = await testRunsApi.CreateEmptyAsync(testRunV2PostShortModel).ConfigureAwait(false) ?? throw new Exception($"Could not find project with id: {settings.ProjectId}");
logger.LogDebug("Created test run {@TestRun}", testRun);

return testRun.Id.ToString();
Expand Down Expand Up @@ -136,7 +137,7 @@ public async Task LinkAutoTestToWorkItemAsync(string autotestId, IEnumerable<str
{
try
{
await autoTestsApi.LinkAutoTestToWorkItemAsync(autotestId, new LinkAutoTestToWorkItemRequest(workItemId ?? string.Empty)).ConfigureAwait(false);
await autoTestsApi.LinkAutoTestToWorkItemAsync(autotestId, new WorkItemIdModel(workItemId ?? string.Empty)).ConfigureAwait(false);
logger.LogDebug(
"Link autotest {AutotestId} to workitem {WorkitemId} is successfully",
autotestId,
Expand Down
4 changes: 2 additions & 2 deletions TmsRunner/TmsRunner.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.6.5</Version>
<Version>1.7.0</Version>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -48,7 +48,7 @@
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
<PackageReference Include="TestIt.ApiClient" Version="3.0.0" />
<PackageReference Include="TestIt.ApiClient" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 7 additions & 4 deletions TmsRunner/Utils/Converter.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using TestIT.ApiClient.Model;
using TmsRunner.Entities.AutoTest;
using AutoTest = TmsRunner.Entities.AutoTest.AutoTest;
using AutoTestStep = TmsRunner.Entities.AutoTest.AutoTestStep;
using AutoTestStepResult = TmsRunner.Entities.AutoTest.AutoTestStepResult;

namespace TmsRunner.Utils;

public static class Converter
{
public static CreateAutoTestRequest ConvertAutoTestDtoToPostModel(AutoTest autotest, string? projectId)
public static AutoTestPostModel ConvertAutoTestDtoToPostModel(AutoTest autotest, string? projectId)
{
var links = autotest.Links?.Select(l =>
new LinkPostModel(
Expand All @@ -15,7 +18,7 @@ public static CreateAutoTestRequest ConvertAutoTestDtoToPostModel(AutoTest autot
Enum.Parse<LinkType>(l.Type.ToString()!))
).ToList();

return new CreateAutoTestRequest(externalId: autotest.ExternalId ?? string.Empty, name: autotest.Name ?? string.Empty)
return new AutoTestPostModel(externalId: autotest.ExternalId ?? string.Empty, name: autotest.Name ?? string.Empty)
{
ExternalId = autotest.ExternalId ?? string.Empty,
Links = links!,
Expand All @@ -31,7 +34,7 @@ public static CreateAutoTestRequest ConvertAutoTestDtoToPostModel(AutoTest autot
};
}

public static UpdateAutoTestRequest ConvertAutoTestDtoToPutModel(AutoTest autotest, string? projectId)
public static AutoTestPutModel ConvertAutoTestDtoToPutModel(AutoTest autotest, string? projectId)
{
var links = autotest.Links?.Select(l =>
new LinkPutModel(
Expand All @@ -42,7 +45,7 @@ public static UpdateAutoTestRequest ConvertAutoTestDtoToPutModel(AutoTest autote
).ToList();


return new UpdateAutoTestRequest(externalId: autotest.ExternalId ?? string.Empty, name: autotest.Name ?? string.Empty)
return new AutoTestPutModel(externalId: autotest.ExternalId ?? string.Empty, name: autotest.Name ?? string.Empty)
{
Links = links ?? [],
ProjectId = new Guid(projectId ?? string.Empty),
Expand Down
7 changes: 4 additions & 3 deletions TmsRunnerTests/Utils/ConverterTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using TestIT.ApiClient.Model;
using TmsRunner.Entities.AutoTest;
using TmsRunner.Utils;
using AutoTest = TmsRunner.Entities.AutoTest.AutoTest;
using AutoTestResult = TmsRunner.Entities.AutoTest.AutoTestResult;

namespace TmsRunnerTests.Utils;

Expand Down Expand Up @@ -37,7 +38,7 @@ public void ConvertAutoTestDtoToPutModel()
var actual = Converter.ConvertAutoTestDtoToPutModel(autotest, id);

// Assert
Assert.IsInstanceOfType<UpdateAutoTestRequest>(actual);
Assert.IsInstanceOfType<AutoTestPutModel>(actual);
Assert.IsNotNull(actual);
}

Expand All @@ -52,7 +53,7 @@ public void ConvertAutoTestDtoToPostModel()
var actual = Converter.ConvertAutoTestDtoToPostModel(autotest, id);

// Assert
Assert.IsInstanceOfType<CreateAutoTestRequest>(actual);
Assert.IsInstanceOfType<AutoTestPostModel>(actual);
Assert.IsNotNull(actual);
}
}
Loading