Skip to content

Commit

Permalink
TmsRunner refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Komissarov committed Mar 26, 2024
1 parent 0c9cd49 commit 6c556ac
Show file tree
Hide file tree
Showing 39 changed files with 1,009 additions and 1,035 deletions.
4 changes: 2 additions & 2 deletions Tms.Adapter.Core/Tms.Adapter.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
<PackageReference Include="TestIt.ApiClient" Version="2.6.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Tms.Adapter.CoreTests/Tms.Adapter.CoreTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
<PackageReference Include="NSubstitute" Version="5.0.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Tms.Adapter/Tms.Adapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<ItemGroup>
<PackageReference Include="Fody" Version="6.6.4" />
<PackageReference Include="MethodBoundaryAspect.Fody" Version="2.0.148" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.5.0" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.9.0" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
</ItemGroup>

Expand Down
63 changes: 63 additions & 0 deletions TmsRunner/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Microsoft.Extensions.Logging;
using TmsRunner.Client;
using TmsRunner.Configuration;
using TmsRunner.Models;
using TmsRunner.Services;

namespace TmsRunner;

public class App(ILogger<App> logger, AdapterConfig adapterConfig, TmsSettings tmsSettings, ITmsClient tmsClient, FilterService filterService, Runner runner)
{
public async Task<int> RunAsync()
{
logger.LogInformation("Adapter works in {Mode} mode", tmsSettings.AdapterMode);
logger.LogDebug("Parameters:");
logger.LogDebug("Runner Path: {Path}", adapterConfig.RunnerPath);
logger.LogDebug("Test Assembly Path: {Path}", adapterConfig.TestAssemblyPath);
logger.LogDebug("Test Adapter Path: {Path}", adapterConfig.TestAdapterPath);
logger.LogDebug("Test Logger Path: {Path}", adapterConfig.LoggerPath);

runner.InitialiseRunner();
var testCases = runner.DiscoverTests();
logger.LogInformation("Discovered Tests Count: {Count}", testCases.Count);

if (testCases.Count == 0)
{
logger.LogInformation("Can not found tests for run");

return 1;
}

switch (tmsSettings.AdapterMode)
{
case 0:
{
var testCaseForRun = await tmsClient.GetAutoTestsForRunAsync(tmsSettings.TestRunId).ConfigureAwait(false);
testCases = filterService.FilterTestCases(adapterConfig.TestAssemblyPath, testCaseForRun, testCases);

break;
}
case 2:
{
tmsSettings.TestRunId = await tmsClient.CreateTestRunAsync().ConfigureAwait(false);

if (!string.IsNullOrEmpty(adapterConfig.TmsLabelsOfTestsToRun))
{
testCases = filterService.FilterTestCasesByLabels(adapterConfig, testCases);
}

break;
}
}

logger.LogInformation("Running tests: {Count}", testCases.Count);
await runner.RunSelectedTestsAsync(testCases).ConfigureAwait(false);

if (tmsSettings.AdapterMode == 2)
{
logger.LogInformation("Test run {TestRunId} finished.", tmsSettings.TestRunId);
}

return 0;
}
}
123 changes: 0 additions & 123 deletions TmsRunner/Client/Converter.cs

This file was deleted.

16 changes: 8 additions & 8 deletions TmsRunner/Client/ITmsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ namespace TmsRunner.Client;

public interface ITmsClient
{
Task<string> CreateTestRun();
Task<List<string>> GetAutoTestsForRun(string testRunId);
Task SubmitResultToTestRun(string guid, AutoTestResult result);
Task<AttachmentModel> UploadAttachment(string fileName, Stream content);
Task<AutoTestModel?> GetAutotestByExternalId(string externalId);
Task<AutoTestModel> CreateAutotest(AutoTest model);
Task UpdateAutotest(AutoTest model);
Task<bool> TryLinkAutoTestToWorkItem(string autotestId, IEnumerable<string> workItemIds);
Task<string?> CreateTestRunAsync();
Task<List<string?>> GetAutoTestsForRunAsync(string? testRunId);
Task SubmitResultToTestRunAsync(string? guid, AutoTestResult result);
Task<AttachmentModel> UploadAttachmentAsync(string fileName, Stream content);
Task<AutoTestModel?> GetAutotestByExternalIdAsync(string? externalId);
Task<AutoTestModel> CreateAutotestAsync(AutoTest model);
Task UpdateAutotestAsync(AutoTest model);
Task<bool> TryLinkAutoTestToWorkItemAsync(string autotestId, IEnumerable<string?> workItemIds);
}
Loading

0 comments on commit 6c556ac

Please sign in to comment.