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 testrunner wrapper #3163

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Text;
using Shouldly;
using Stryker.Abstractions.Mutants;
using Stryker.Abstractions;
using Stryker.Abstractions.Reporting;
using Stryker.Core.Reporters.Json;
using Xunit;
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,16 +1,15 @@
using Microsoft.CodeAnalysis;
using Stryker.Abstractions.Mutators;

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

/// <summary>
/// Represents a single mutation on code level
/// </summary>
public class Mutation
{
public SyntaxNode OriginalNode { get; set; }

Check warning on line 10 in src/Stryker.Abstractions/Mutation.cs

View workflow job for this annotation

GitHub Actions / integration-test

Non-nullable property 'OriginalNode' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 10 in src/Stryker.Abstractions/Mutation.cs

View workflow job for this annotation

GitHub Actions / integration-test

Non-nullable property 'OriginalNode' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public SyntaxNode ReplacementNode { get; set; }

Check warning on line 11 in src/Stryker.Abstractions/Mutation.cs

View workflow job for this annotation

GitHub Actions / integration-test

Non-nullable property 'ReplacementNode' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 11 in src/Stryker.Abstractions/Mutation.cs

View workflow job for this annotation

GitHub Actions / integration-test

Non-nullable property 'ReplacementNode' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public string DisplayName { get; set; }

Check warning on line 12 in src/Stryker.Abstractions/Mutation.cs

View workflow job for this annotation

GitHub Actions / integration-test

Non-nullable property 'DisplayName' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 12 in src/Stryker.Abstractions/Mutation.cs

View workflow job for this annotation

GitHub Actions / integration-test

Non-nullable property 'DisplayName' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public Mutator Type { get; set; }
public string Description { get; set; }

Check warning on line 14 in src/Stryker.Abstractions/Mutation.cs

View workflow job for this annotation

GitHub Actions / integration-test

Non-nullable property 'Description' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 14 in src/Stryker.Abstractions/Mutation.cs

View workflow job for this annotation

GitHub Actions / integration-test

Non-nullable property 'Description' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
}
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 All @@ -16,7 +16,7 @@

public string Description { get; set; }

public override bool Equals([NotNullWhen(true)] object obj) =>

Check warning on line 19 in src/Stryker.Abstractions/MutatorDescriptionAttribute.cs

View workflow job for this annotation

GitHub Actions / integration-test

Nullability of type of parameter 'obj' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 19 in src/Stryker.Abstractions/MutatorDescriptionAttribute.cs

View workflow job for this annotation

GitHub Actions / integration-test

Nullability of type of parameter 'obj' doesn't match overridden member (possibly because of nullability attributes).
obj is MutatorDescriptionAttribute other && other.Description == Description;

public override int GetHashCode() => Description?.GetHashCode() ?? 0;
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
2 changes: 1 addition & 1 deletion src/Stryker.Abstractions/ProjectComponents/ITestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Stryker.Abstractions.ProjectComponents;

public interface ITestCase
{
Guid Id { get; init; }
string 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(string 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
{
string 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; }

string Id { get; }

int NbSubCases { get; }

ITestCase Case { get; }

void RegisterInitialTestResult(ITestResult result);

void AddSubCase();

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

namespace Stryker.Abstractions.Testing;

public interface ITestCase
{
string Id { get; }

Guid Guid { 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
{
string 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<string> GetIdentifiers();
int Count { get; }
bool IsEmpty { get; }
bool IsEveryTest { get; }
ITestIdentifiers Merge(ITestIdentifiers other);
bool Contains(string 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; }
}
22 changes: 22 additions & 0 deletions src/Stryker.Abstractions/Testing/ITestRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;

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[string id] { get; }
void RegisterTests(IEnumerable<ITestDescription> tests);
void RegisterTest(ITestDescription test);
IEnumerable<ITestDescription> Extract(IEnumerable<string> ids);
}
19 changes: 19 additions & 0 deletions src/Stryker.Abstractions/Testing/MutationTestingRequirements.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;

namespace Stryker.Abstractions.Testing;

[Flags]
public enum MutationTestingRequirements
{
None = 0,
// mutation is static or executed inside à static context
Static = 1,
// mutation is covered outside test (before or after)
CoveredOutsideTest = 2,
// mutation needs to be activated ASAP when tested
NeedEarlyActivation = 4,
// mutation needs to be run in 'all tests' mode
AgainstAllTests = 8,
// not covered
NotCovered = 256
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
using System;
namespace Stryker.Abstractions.Testing;

namespace Stryker.Core.Mutants;

public sealed class TestDescription
public sealed class TestDescription : ITestDescription
{
public TestDescription(Guid id, string name, string testFilePath)
public TestDescription(string id, string name, string testFilePath)
{
Id = id;
Name = name;
TestFilePath = testFilePath;
}

public Guid Id { get; }
public string Id { get; }

public string Name { get; }

Expand All @@ -21,7 +19,8 @@
{
return Id == other.Id;
}

public override bool Equals(object obj)

Check warning on line 23 in src/Stryker.Abstractions/Testing/TestDescription.cs

View workflow job for this annotation

GitHub Actions / integration-test

Nullability of type of parameter 'obj' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 23 in src/Stryker.Abstractions/Testing/TestDescription.cs

View workflow job for this annotation

GitHub Actions / integration-test

Nullability of type of parameter 'obj' doesn't match overridden member (possibly because of nullability attributes).
{
if (obj is null)
return false;
Expand Down
Loading
Loading