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

chore: Add wrapper for testrunners #3148

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<Project>
<ItemGroup>
<PackageVersion Include="Azure.Storage.Files.Shares" Version="12.21.0" />
<PackageVersion Include="dnlib" Version="4.4.0" />
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.2.25" />
<PackageVersion Include="LaunchDarkly.EventSource" Version="5.1.0" />
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageVersion Include="MSTest" Version="3.7.0" />
<PackageVersion Include="MSTest.TestFramework" Version="3.7.0" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.7.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="1.5.0" />
<PackageVersion Include="Microsoft.Testing.Platform" Version="1.5.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageVersion Include="NuGet.Protocol" Version="6.12.1" />
<PackageVersion Include="ResXResourceReader.NetStandard" Version="1.3.0" />
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="21.1.7" />
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
<PackageVersion Include="Grynwald.MarkdownGenerator" Version="3.0.106" />
<PackageVersion Include="LibGit2Sharp" Version="0.31.0" />
Expand Down
13 changes: 6 additions & 7 deletions src/Stryker.Abstractions/IMutant.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
using Stryker.Abstractions.TestRunners;
using Stryker.Abstractions;
using Stryker.Abstractions.Testing;

namespace Stryker.Abstractions.Mutants;
namespace Stryker.Abstractions;

public interface IMutant : IReadOnlyMutant
{
new int Id { get; set; }
new Mutation Mutation { get; set; }
new MutantStatus ResultStatus { get; set; }
new string ResultStatusReason { get; set; }
new ITestGuids CoveringTests { get; set; }
new ITestGuids KillingTests { get; set; }
new ITestGuids AssessingTests { get; set; }
new ITestIdentifiers CoveringTests { get; set; }
new ITestIdentifiers KillingTests { get; set; }
new ITestIdentifiers AssessingTests { get; set; }
new bool CountForStats { get; }
new bool IsStaticValue { get; set; }

string DisplayName { get; }
bool MustBeTestedInIsolation { get; set; }

void AnalyzeTestRun(ITestGuids failedTests, ITestGuids resultRanTests, ITestGuids timedOutTests, bool sessionTimedOut);
void AnalyzeTestRun(ITestIdentifiers failedTests, ITestIdentifiers resultRanTests, ITestIdentifiers timedOutTests, bool sessionTimedOut);
}
3 changes: 1 addition & 2 deletions src/Stryker.Abstractions/IMutator.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Microsoft.CodeAnalysis;
using Stryker.Abstractions.Options;
using Stryker.Abstractions.Mutants;
using System.Collections.Generic;

namespace Stryker.Abstractions.Mutators;
namespace Stryker.Abstractions;

public interface IMutator
{
Expand Down
4 changes: 2 additions & 2 deletions src/Stryker.Abstractions/IProjectAndTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using Stryker.Abstractions.ProjectComponents;

namespace Stryker.Abstractions.Initialisation;
namespace Stryker.Abstractions;

public interface IProjectAndTests
{
ITestProjectsInfo TestProjectsInfo { get;}
ITestProjectsInfo TestProjectsInfo { get; }

string HelperNamespace { get; }

Expand Down
9 changes: 4 additions & 5 deletions src/Stryker.Abstractions/IReadOnlyMutant.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Stryker.Abstractions.TestRunners;
using Stryker.Abstractions.Mutants;
using Stryker.Abstractions.Testing;

namespace Stryker.Abstractions;

Expand All @@ -12,9 +11,9 @@ public interface IReadOnlyMutant
Mutation Mutation { get; }
MutantStatus ResultStatus { get; }
string ResultStatusReason { get; }
ITestGuids CoveringTests { get; }
ITestGuids KillingTests { get; }
ITestGuids AssessingTests { get; }
ITestIdentifiers CoveringTests { get; }
ITestIdentifiers KillingTests { get; }
ITestIdentifiers AssessingTests { get; }
bool CountForStats { get; }
bool IsStaticValue { get; }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Stryker.Core.Initialisation;
namespace Stryker.Abstractions;

public enum Language
{
Expand Down
2 changes: 1 addition & 1 deletion src/Stryker.Abstractions/MutantStatus.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Stryker.Abstractions.Mutants;
namespace Stryker.Abstractions;

public enum MutantStatus
{
Expand Down
3 changes: 1 addition & 2 deletions src/Stryker.Abstractions/Mutation.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.CodeAnalysis;
using Stryker.Abstractions.Mutators;

namespace Stryker.Abstractions.Mutants;
namespace Stryker.Abstractions;

/// <summary>
/// Represents a single mutation on code level
Expand Down
2 changes: 1 addition & 1 deletion src/Stryker.Abstractions/MutationLevel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Stryker.Abstractions.Mutators;
namespace Stryker.Abstractions;

public enum MutationLevel
{
Expand Down
4 changes: 1 addition & 3 deletions src/Stryker.Abstractions/Mutator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Stryker.Utilities.Attributes;

namespace Stryker.Abstractions.Mutators;
namespace Stryker.Abstractions;

public enum Mutator
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;

namespace Stryker.Utilities.Attributes;
namespace Stryker.Abstractions;

[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
public class MutatorDescriptionAttribute : Attribute
Expand Down
1 change: 0 additions & 1 deletion src/Stryker.Abstractions/Options/IStrykerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Text.RegularExpressions;
using Microsoft.CodeAnalysis.CSharp;
using Stryker.Abstractions.Baseline;
using Stryker.Abstractions.Mutators;
using Stryker.Abstractions.ProjectComponents;

namespace Stryker.Abstractions.Options;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Stryker.Abstractions.Mutants;
using Stryker.Abstractions.Options;

namespace Stryker.Abstractions.ProjectComponents;
Expand Down
3 changes: 1 addition & 2 deletions src/Stryker.Abstractions/ProjectComponents/ITestCase.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System;
using Microsoft.CodeAnalysis;

namespace Stryker.Abstractions.ProjectComponents;

public interface ITestCase
{
Guid Id { get; init; }
Testing.Identifier Id { get; init; }
string Name { get; init; }
SyntaxNode Node { get; init; }

Expand Down
4 changes: 2 additions & 2 deletions src/Stryker.Abstractions/ProjectComponents/ITestFile.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis;
using Stryker.Abstractions.Testing;

namespace Stryker.Abstractions.ProjectComponents;

Expand All @@ -11,7 +11,7 @@ public interface ITestFile
SyntaxTree SyntaxTree { get; init; }
IList<ITestCase> Tests { get; }

void AddTest(Guid id, string name, SyntaxNode node);
void AddTest(Identifier id, string name, SyntaxNode node);
bool Equals(object obj);
bool Equals(ITestFile other);
int GetHashCode();
Expand Down
5 changes: 0 additions & 5 deletions src/Stryker.Abstractions/Stryker.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@
<PackageReference Include="Serilog" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Stryker.Utilities\Stryker.Utilities.csproj" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions src/Stryker.Abstractions/Testing/CoverageConfidence.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Stryker.Abstractions.Testing;

public enum CoverageConfidence
{
Exact,
Normal,
Dubious,
UnexpectedCase
}
13 changes: 13 additions & 0 deletions src/Stryker.Abstractions/Testing/ICoverageRunResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;

namespace Stryker.Abstractions.Testing;

public interface ICoverageRunResult
{
Identifier TestId { get; }
Dictionary<int, MutationTestingRequirements> MutationFlags { get; }
IReadOnlyCollection<int> MutationsCovered { get; }
MutationTestingRequirements this[int mutation] { get; }
CoverageConfidence Confidence { get; }
void Merge(ICoverageRunResult coverageRunResult);
}
24 changes: 24 additions & 0 deletions src/Stryker.Abstractions/Testing/IFrameworkTestDescription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;

namespace Stryker.Abstractions.Testing;

public interface IFrameworkTestDescription
{
TestFrameworks Framework { get; }

ITestDescription Description { get; }

TimeSpan InitialRunTime { get; }

Identifier Id { get; }

int NbSubCases { get; }

ITestCase Case { get; }

void RegisterInitialTestResult(ITestResult result);

void AddSubCase();

void ClearInitialResult();
}
20 changes: 20 additions & 0 deletions src/Stryker.Abstractions/Testing/ITestCase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;

namespace Stryker.Abstractions.Testing;

public interface ITestCase
{
Identifier Id { get; }

string Name { get; }

string Source { get; }

string CodeFilePath { get; }

string FullyQualifiedName { get; }

Uri Uri { get; }

int LineNumber { get; }
}
8 changes: 8 additions & 0 deletions src/Stryker.Abstractions/Testing/ITestDescription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Stryker.Abstractions.Testing;

public interface ITestDescription
{
Identifier Id { get; }
string Name { get; }
string TestFilePath { get; }
}
2 changes: 1 addition & 1 deletion src/Stryker.Abstractions/Testing/ITestGuids.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;

namespace Stryker.Abstractions.TestRunners;
namespace Stryker.Abstractions.Testing;

// represents a simple list of test identifier with some properties
public interface ITestGuids
Expand Down
17 changes: 17 additions & 0 deletions src/Stryker.Abstractions/Testing/ITestIdentifiers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;

namespace Stryker.Abstractions.Testing;

public interface ITestIdentifiers
{
IEnumerable<Identifier> GetIdentifiers();
int Count { get; }
bool IsEmpty { get; }
bool IsEveryTest { get; }
ITestIdentifiers Merge(ITestIdentifiers other);
bool Contains(Identifier testId);
bool ContainsAny(ITestIdentifiers other);
bool IsIncludedIn(ITestIdentifiers other);
ITestIdentifiers Intersect(ITestIdentifiers other);
ITestIdentifiers Excluding(ITestIdentifiers testsToSkip);
}
8 changes: 8 additions & 0 deletions src/Stryker.Abstractions/Testing/ITestResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace Stryker.Abstractions.Testing;

public interface ITestResult
{
TimeSpan Duration { get; }
}
16 changes: 16 additions & 0 deletions src/Stryker.Abstractions/Testing/ITestRunResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;

namespace Stryker.Abstractions.Testing;

public interface ITestRunResult
{
TimeSpan Duration { get; }
ITestIdentifiers ExecutedTests { get; }
ITestIdentifiers FailingTests { get; }
IEnumerable<string> Messages { get; }
string ResultMessage { get; }
bool SessionTimedOut { get; }
ITestIdentifiers TimedOutTests { get; }
IEnumerable<IFrameworkTestDescription> TestDescriptions { get; }
}
23 changes: 23 additions & 0 deletions src/Stryker.Abstractions/Testing/ITestRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using Stryker.Abstractions;

namespace Stryker.Abstractions.Testing;

public interface ITestRunner : IDisposable
{
public delegate bool TestUpdateHandler(IReadOnlyList<IMutant> testedMutants,
ITestIdentifiers failedTests,
ITestIdentifiers ranTests,
ITestIdentifiers timedOutTests);

bool DiscoverTests(string assembly);

ITestSet GetTests(IProjectAndTests project);

ITestRunResult InitialTest(IProjectAndTests project);

IEnumerable<ICoverageRunResult> CaptureCoverage(IProjectAndTests project);

ITestRunResult TestMultipleMutants(IProjectAndTests project, ITimeoutValueCalculator timeoutCalc, IReadOnlyList<IMutant> mutants, TestUpdateHandler update);
}
12 changes: 12 additions & 0 deletions src/Stryker.Abstractions/Testing/ITestSet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Generic;

namespace Stryker.Abstractions.Testing;

public interface ITestSet
{
int Count { get; }
ITestDescription this[Identifier id] { get; }
void RegisterTests(IEnumerable<ITestDescription> tests);
void RegisterTest(ITestDescription test);
IEnumerable<ITestDescription> Extract(IEnumerable<Identifier> ids);
}
34 changes: 34 additions & 0 deletions src/Stryker.Abstractions/Testing/Identifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;

namespace Stryker.Abstractions.Testing;

public class Identifier : IEquatable<Identifier>
{
private readonly string _identifier;

private Identifier(string identifier) => _identifier = identifier;

public static Identifier Create(string identifier) => new(identifier);

public static Identifier Create(Guid guid) => new(guid.ToString());

public static Identifier Empty => new(Guid.Empty.ToString());

public Guid ToGuid()
{
var isGuid = Guid.TryParse(_identifier, out var guid);
return isGuid ? guid : Guid.Empty;
}

public override int GetHashCode() => _identifier.GetHashCode();

public override string ToString() => _identifier;

public override bool Equals(object obj) => obj is Identifier identifier && Equals(identifier);

public bool Equals(Identifier other) => _identifier == other?._identifier;

public static bool operator ==(Identifier left, Identifier right) => Equals(left, right);

public static bool operator !=(Identifier left, Identifier right) => !Equals(left, right);
}
Loading