Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="7.1.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="FsCheck.Xunit" Version="3.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNetAnalyser.Benchmarks;
using FluentAssertions;
using Shouldly;
using Xunit;

namespace BenchmarkDotNetAnalyser.Tests.Integration.Classes.Benchmarks
Expand Down Expand Up @@ -35,7 +35,7 @@ public async Task GetBenchmarkInfosAsync_WriteBenchmarkInfosAsync_Symmetric(stri
var readResult = await p.GetBenchmarkInfosAsync(dir);
var readResultCount = readResult.Sum(r => r.Runs.Sum(x => x.Results.Count));

benchmarkInfosResultCount.Should().Be(readResultCount);
benchmarkInfosResultCount.ShouldBe(readResultCount);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNetAnalyser.Benchmarks;
using BenchmarkDotNetAnalyser.IO;
using FluentAssertions;
using Shouldly;
using Xunit;

namespace BenchmarkDotNetAnalyser.Tests.Integration.Classes.Benchmarks
Expand Down Expand Up @@ -49,9 +49,9 @@

var result = new BenchmarkParser(json).GetCreation();

result.Should().BeAfter(default);
result.Year.Should().BeGreaterThan(2020);
result.Year.Should().BeLessThan(2100);
result.ShouldBeGreaterThan(default);
result.Year.ShouldBeGreaterThan(2020);
result.Year.ShouldBeLessThan(2100);
}

[Theory]
Expand All @@ -63,16 +63,24 @@
var jo = Newtonsoft.Json.Linq.JObject.Parse(json)["HostEnvironmentInfo"];
var result = new BenchmarkParser(json).GetBenchmarkEnvironment();

result.Should().NotBeNull();
result.BenchmarkDotNetVersion.Should().Be(jo.GetStringValue("BenchmarkDotNetVersion")).And.NotBeNullOrWhiteSpace();
result.DotNetCliVersion.Should().Be(jo.Value<string>("DotNetCliVersion")).And.NotBeNullOrWhiteSpace();
result.DotNetRuntimeVersion.Should().Be(jo.Value<string>("RuntimeVersion")).And.NotBeNullOrWhiteSpace();
result.OsVersion.Should().Be(jo.Value<string>("OsVersion")).And.NotBeNullOrWhiteSpace();
result.ProcessorName.Should().Be(jo.Value<string>("ProcessorName")).And.NotBeNullOrWhiteSpace();

result.PhysicalProcessorCount.Should().Be(jo.Value<int>("PhysicalProcessorCount")).And.BeGreaterThan(0);
result.LogicalCoreCount.Should().Be(jo.Value<int>("LogicalCoreCount")).And.BeGreaterThan(0);
result.MachineArchitecture.Should().Be(jo.Value<string>("Architecture")).And.NotBeNullOrWhiteSpace();
result.ShouldNotBeNull();
result.BenchmarkDotNetVersion.ShouldBe(jo.GetStringValue("BenchmarkDotNetVersion"));
result.BenchmarkDotNetVersion.ShouldNotBeNullOrWhiteSpace();
result.DotNetCliVersion.ShouldBe(jo.Value<string>("DotNetCliVersion"));
result.DotNetCliVersion.ShouldNotBeNullOrWhiteSpace();
result.DotNetRuntimeVersion.ShouldBe(jo.Value<string>("RuntimeVersion"));
result.DotNetRuntimeVersion.ShouldNotBeNullOrWhiteSpace();
result.OsVersion.ShouldBe(jo.Value<string>("OsVersion"));
result.OsVersion.ShouldNotBeNullOrWhiteSpace();
result.ProcessorName.ShouldBe(jo.Value<string>("ProcessorName"));
result.ProcessorName.ShouldNotBeNullOrWhiteSpace();

result.PhysicalProcessorCount.ShouldBe(jo.Value<int>("PhysicalProcessorCount"));
result.PhysicalProcessorCount.ShouldBeGreaterThan(0);
result.LogicalCoreCount.ShouldBe(jo.Value<int>("LogicalCoreCount"));
result.LogicalCoreCount.ShouldBeGreaterThan(0);
result.MachineArchitecture.ShouldBe(jo.Value<string>("Architecture"));
result.MachineArchitecture.ShouldNotBeNullOrWhiteSpace();
}

[Theory]
Expand All @@ -82,22 +90,32 @@
var json = await FileReader.ReadAsync(filePath);
var results = new BenchmarkParser(json).GetBenchmarkResults().ToList();

results.Count.Should().BeGreaterThan(0);
results.Count.ShouldBeGreaterThan(0);

foreach (var result in results)
{
result.FullName.Should().NotBeNullOrWhiteSpace().And.ContainAny(_benchmarkTypeFullNames);
result.Namespace.Should().NotBeNullOrWhiteSpace().And.ContainAny(_benchmarkTypeNamespaces);
result.Type.Should().NotBeNullOrWhiteSpace().And.ContainAny(_benchmarkTypeNames);
result.Method.Should().NotBeNullOrWhiteSpace().And.ContainAny(_benchmarkMethods);
result.Parameters.Should().NotBeNull();

result.MaxTime.Should().HaveValue().And.BeGreaterOrEqualTo(0M);
result.MinTime.Should().HaveValue().And.BeGreaterOrEqualTo(0M);
result.MeanTime.Should().HaveValue().And.BeGreaterOrEqualTo(0M);
result.MedianTime.Should().HaveValue().And.BeGreaterOrEqualTo(0M);
result.Q1Time.Should().HaveValue().And.BeGreaterOrEqualTo(0M);
result.Q3Time.Should().HaveValue().And.BeGreaterOrEqualTo(0M);
result.FullName.ShouldNotBeNullOrWhiteSpace();
_benchmarkTypeFullNames.Any(x => result.FullName.Contains(x)).ShouldBeTrue();
result.Namespace.ShouldNotBeNullOrWhiteSpace();
_benchmarkTypeNamespaces.Any(x => result.Namespace.Contains(x)).ShouldBeTrue();
result.Type.ShouldNotBeNullOrWhiteSpace();
_benchmarkTypeNames.Any(x => result.Type.Contains(x)).ShouldBeTrue();
result.Method.ShouldNotBeNullOrWhiteSpace();
_benchmarkMethods.Any(x => result.Method.Contains(x)).ShouldBeTrue();
result.Parameters.ShouldNotBeNull();

result.MaxTime.ShouldNotBeNull();
result.MaxTime.Value.ShouldBeGreaterThanOrEqualTo(0M);
result.MinTime.ShouldNotBeNull();
result.MinTime.Value.ShouldBeGreaterThanOrEqualTo(0M);
result.MeanTime.ShouldNotBeNull();
result.MeanTime.Value.ShouldBeGreaterThanOrEqualTo(0M);
result.MedianTime.ShouldNotBeNull();
result.MedianTime.Value.ShouldBeGreaterThanOrEqualTo(0M);
result.Q1Time.ShouldNotBeNull();
result.Q1Time.Value.ShouldBeGreaterThanOrEqualTo(0M);
result.Q3Time.ShouldNotBeNull();
result.Q3Time.Value.ShouldBeGreaterThanOrEqualTo(0M);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNetAnalyser.Benchmarks;
using FluentAssertions;
using Shouldly;
using Xunit;

namespace BenchmarkDotNetAnalyser.Tests.Integration.Classes.Benchmarks
Expand All @@ -19,7 +19,7 @@ public async Task GetBenchmarkResultsAsync_ResultsReturned(string path)

var result = await reader.GetBenchmarkResultsAsync(path);

result.Count.Should().BeGreaterThan(0);
result.Count.ShouldBeGreaterThan(0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNetAnalyser.Benchmarks;
using FluentAssertions;
using Shouldly;
using Xunit;

namespace BenchmarkDotNetAnalyser.Tests.Integration.Classes.Benchmarks
Expand All @@ -20,10 +20,10 @@ public async Task GetBenchmarkJsonAsync_ResultsParsed(string path)

var result = await provider.GetRunInfoAsync(path);

result.Should().NotBeNull();
result.BenchmarkDotNetVersion.Should().NotBeNullOrWhiteSpace();
result.Creation.Should().NotBe(DateTimeOffset.MinValue);
result.Results.Count.Should().BeGreaterThan(0);
result.ShouldNotBeNull();
result.BenchmarkDotNetVersion.ShouldNotBeNullOrWhiteSpace();
result.Creation.ShouldNotBe(DateTimeOffset.MinValue);
result.Results.Count.ShouldBeGreaterThan(0);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Linq;
using BenchmarkDotNetAnalyser.IO;
using FluentAssertions;
using Shouldly;
using Xunit;

namespace BenchmarkDotNetAnalyser.Tests.Integration.Classes.IO
Expand All @@ -18,9 +18,9 @@ public void Find_ReturnsFiles()

var expected = IOHelper.GetSourceResultFilePaths().ToList();

result.Count.Should().BeGreaterThan(0);
result.SequenceEqual(expected).Should().BeTrue();
result.All(x => x.EndsWith(ext)).Should().BeTrue();
result.Count.ShouldBeGreaterThan(0);
result.SequenceEqual(expected).ShouldBeTrue();
result.All(x => x.EndsWith(ext)).ShouldBeTrue();
}
}
}
70 changes: 35 additions & 35 deletions test/BenchmarkDotNetAnalyser.Tests.Integration/E2E/BaseStory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
using BenchmarkDotNetAnalyser.Instrumentation;
using BenchmarkDotNetAnalyser.IO;
using BenchmarkDotNetAnalyser.Reporting;
using FluentAssertions;
using FluentAssertions.Execution;
using Shouldly;

using Newtonsoft.Json;
using NSubstitute;

Expand Down Expand Up @@ -89,7 +89,7 @@ public async Task AggregationExecutorExecuted(bool expectedResult = true)

_aggregateResult = await aggregator.ExecuteAsync(_aggregateArgs);

_aggregateResult.Should().Be(expectedResult);
_aggregateResult.ShouldBe(expectedResult);
}

public async Task AggregatedBenchmarkInfosFetched()
Expand All @@ -101,34 +101,34 @@ public async Task AggregatedBenchmarkInfosFetched()

public void SingletonBenchmarkInfoIsChecked()
{
_newBenchmarkInfos.Count.Should().Be(1);
_newBenchmarkInfos.Count.ShouldBe(1);

_newBenchmarkInfos[0].BranchName.Should().Be(_aggregateArgs.BranchName);
_newBenchmarkInfos[0].CommitSha.Should().Be(_aggregateArgs.CommitSha);
_newBenchmarkInfos[0].BuildUri.Should().Be(_aggregateArgs.BuildUri);
_newBenchmarkInfos[0].Tags.Should().BeEquivalentTo(_aggregateArgs.Tags);
_newBenchmarkInfos[0].BranchName.ShouldBe(_aggregateArgs.BranchName);
_newBenchmarkInfos[0].CommitSha.ShouldBe(_aggregateArgs.CommitSha);
_newBenchmarkInfos[0].BuildUri.ShouldBe(_aggregateArgs.BuildUri);
_newBenchmarkInfos[0].Tags.ShouldBe(_aggregateArgs.Tags);

_newBenchmarkInfos[0].Runs.Should().HaveCount(_newRunFiles);
_newBenchmarkInfos[0].Runs.Count.ShouldBe(_newRunFiles);

_newBenchmarkInfos[0].Runs.All(p => !string.IsNullOrWhiteSpace(p.BenchmarkDotNetVersion)).Should().BeTrue();
_newBenchmarkInfos[0].Runs.All(p => p.Creation > DateTimeOffset.MinValue).Should().BeTrue();
_newBenchmarkInfos[0].Runs.All(p => !string.IsNullOrWhiteSpace(p.BenchmarkDotNetVersion)).ShouldBeTrue();
_newBenchmarkInfos[0].Runs.All(p => p.Creation > DateTimeOffset.MinValue).ShouldBeTrue();
}

public void MultipleBenchmarkInfosAreChecked()
{
_newBenchmarkInfos.Count.Should().Be(_aggregateArgs.BenchmarkRuns);
_newBenchmarkInfos.Count.ShouldBe(_aggregateArgs.BenchmarkRuns);

foreach (var bi in _newBenchmarkInfos)
{
bi.BranchName.Should().Be(_aggregateArgs.BranchName);
bi.CommitSha.Should().Be(_aggregateArgs.CommitSha);
bi.BuildUri.Should().Be(_aggregateArgs.BuildUri);
bi.Tags.Should().BeEquivalentTo(_aggregateArgs.Tags);
bi.BranchName.ShouldBe(_aggregateArgs.BranchName);
bi.CommitSha.ShouldBe(_aggregateArgs.CommitSha);
bi.BuildUri.ShouldBe(_aggregateArgs.BuildUri);
bi.Tags.ShouldBe(_aggregateArgs.Tags);

bi.Runs.Should().HaveCount(_newRunFiles);
bi.Runs.Count.ShouldBe(_newRunFiles);

bi.Runs.All(p => !string.IsNullOrWhiteSpace(p.BenchmarkDotNetVersion)).Should().BeTrue();
bi.Runs.All(p => p.Creation > DateTimeOffset.MinValue).Should().BeTrue();
bi.Runs.All(p => !string.IsNullOrWhiteSpace(p.BenchmarkDotNetVersion)).ShouldBeTrue();
bi.Runs.All(p => p.Creation > DateTimeOffset.MinValue).ShouldBeTrue();
}
}

Expand All @@ -141,7 +141,7 @@ public void BenchmarkRunResultsRetrieved()

public void EmptyBenchmarkRunResultsChecked()
{
_benchmarkRunResults.Count.Should().Be(0);
_benchmarkRunResults.Count.ShouldBe(0);
}

public void BenchmarkRunResultsChecked()
Expand All @@ -150,12 +150,12 @@ public void BenchmarkRunResultsChecked()

foreach (var br in results)
{
br.FullName.Should().NotBeNullOrWhiteSpace();
br.Method.Should().NotBeNullOrWhiteSpace();
br.Namespace.Should().NotBeNullOrWhiteSpace();
br.FullName.ShouldNotBeNullOrWhiteSpace();
br.Method.ShouldNotBeNullOrWhiteSpace();
br.Namespace.ShouldNotBeNullOrWhiteSpace();
}
_benchmarkRunResults.All(brr => brr.Results.Count > 0).Should().BeTrue();
_benchmarkRunResults.All(brr => brr.Run != null).Should().BeTrue();
_benchmarkRunResults.All(brr => brr.Results.Count > 0).ShouldBeTrue();
_benchmarkRunResults.All(brr => brr.Run != null).ShouldBeTrue();
}

public void AnalysisArgsCreated(decimal tolerance, int maxErrors)
Expand All @@ -175,20 +175,20 @@ public async Task AnalysisExecutorExecuted()

_analysisResult = await analyser.ExecuteAsync(_analysisArgs);

_analysisResult.Should().NotBeNull();
_analysisResult.ShouldNotBeNull();
}

public void AnalysisResultCheckedForSuccess()
{
_analysisResult.MeetsRequirements.Should().BeTrue();
_analysisResult.InnerResults.Any(bra => bra.MeetsRequirements).Should().BeTrue();
_analysisResult.InnerResults.Count.Should().BeGreaterThan(0);
_analysisResult.MeetsRequirements.ShouldBeTrue();
_analysisResult.InnerResults.Any(bra => bra.MeetsRequirements).ShouldBeTrue();
_analysisResult.InnerResults.Count.ShouldBeGreaterThan(0);
}

public void AnalysisResultCheckedForFailure()
{
_analysisResult.MeetsRequirements.Should().BeFalse();
_analysisResult.Message.Should().NotBeNullOrWhiteSpace();
_analysisResult.MeetsRequirements.ShouldBeFalse();
_analysisResult.Message.ShouldNotBeNullOrWhiteSpace();
}

public void ReportsDirectoryCreated()
Expand Down Expand Up @@ -221,7 +221,7 @@ public void CsvReportsAreVerified()
{
if (!File.Exists(file))
{
throw new AssertionFailedException($"File {file} does not exist.");
throw new Exception($"File {file} does not exist.");
}

using (var stream = File.OpenText(file))
Expand All @@ -230,7 +230,7 @@ public void CsvReportsAreVerified()
{
var recs = csvReader.GetRecords<object>().ToList();

recs.Count.Should().BeGreaterThan(0);
recs.Count.ShouldBeGreaterThan(0);
}
}
}
Expand All @@ -244,12 +244,12 @@ public void JsonReportsAreVerified()
{
if (!File.Exists(file))
{
throw new AssertionFailedException($"File {file} does not exist.");
throw new Exception($"File {file} does not exist.");
}

var json = File.ReadAllText(file);
var records = JsonConvert.DeserializeObject<IList<BenchmarkRecord>>(json);
records.Count.Should().BeGreaterThan(0);
records.Count.ShouldBeGreaterThan(0);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using BenchmarkDotNetAnalyser.Analysis;
using BenchmarkDotNetAnalyser.Benchmarks;
using FluentAssertions;
using Shouldly;
using FsCheck;
using FsCheck.Xunit;
using Xunit;
Expand Down Expand Up @@ -69,7 +69,7 @@ public void CreateAnalysis_ToleranceHasPositiveNegativeBoundaries_OutsideBoundar

var result = analyser.CreateAnalysis("", baseline, test);

result.MeetsRequirements.Should().BeFalse();
result.MeetsRequirements.ShouldBeFalse();
}

[Theory]
Expand All @@ -85,7 +85,7 @@ public void CreateAnalysis_ToleranceHasPositiveNegativeBoundaries_InsideBoundari

var result = analyser.CreateAnalysis("", baseline, test);

result.MeetsRequirements.Should().BeTrue();
result.MeetsRequirements.ShouldBeTrue();
}
}
}
Loading