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
29 changes: 28 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,39 @@ jobs:
cd Tests
../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext"

benchmark:
name: Run benchmarks
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: Build solution
run: dotnet build /p:NetCoreOnly=True --configuration "Release"
- name: Run benchmark
run: cd Build/Tests/Testably.Expectations.Benchmarks && dotnet ./Testably.Expectations.Benchmarks.dll --exporters json --filter '*'
- name: Store benchmark result
uses: rhysd/github-action-benchmark@v1
with:
name: Benchmark.Net Benchmark
tool: 'benchmarkdotnet'
output-file-path: Build/Tests/Testably.Expectations.Benchmarks/BenchmarkDotNet.Artifacts/results/Testably.Expectations.Benchmarks.HappyCaseBenchmarks-report-full-compressed.json
github-token: ${{ secrets.GITHUB_TOKEN }}
gh-pages-branch: 'benchmarks'
benchmark-data-dir-path: 'Docs/Benchmarks'
auto-push: true

deploy:
name: Deploy
if: startsWith(github.ref, 'refs/heads/release/')
runs-on: ubuntu-latest
environment: production
needs: [test-macos, test-ubuntu, test-windows, test-net-framework, stryker]
needs: [test-macos, test-ubuntu, test-windows, test-net-framework, stryker, benchmark]
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down
7 changes: 7 additions & 0 deletions Testably.Expectations.sln
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "API", "API", "{8E66A739-A8B
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testably.Expectations.Internal.Tests", "Tests\Testably.Expectations.Internal.Tests\Testably.Expectations.Internal.Tests.csproj", "{0A57A213-E281-4B92-8005-E242DD34B04E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testably.Expectations.Benchmarks", "Tests\Testably.Expectations.Benchmarks\Testably.Expectations.Benchmarks.csproj", "{CEA70C41-62D0-406C-9A17-5578A54E93CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -119,6 +121,10 @@ Global
{0A57A213-E281-4B92-8005-E242DD34B04E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A57A213-E281-4B92-8005-E242DD34B04E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A57A213-E281-4B92-8005-E242DD34B04E}.Release|Any CPU.Build.0 = Release|Any CPU
{CEA70C41-62D0-406C-9A17-5578A54E93CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEA70C41-62D0-406C-9A17-5578A54E93CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEA70C41-62D0-406C-9A17-5578A54E93CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEA70C41-62D0-406C-9A17-5578A54E93CA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -141,6 +147,7 @@ Global
{E5E419DE-412D-4E44-8C6B-BA324DFCAE4A} = {81590DC1-DAC3-41B9-8696-2024E31F493A}
{8E66A739-A8B3-45D7-A69E-36F0231C5E24} = {7D94B2A0-9ED6-4186-9635-64637C55556F}
{0A57A213-E281-4B92-8005-E242DD34B04E} = {E08785BF-6C98-4CAC-BFC2-BBB79B522DD6}
{CEA70C41-62D0-406C-9A17-5578A54E93CA} = {E08785BF-6C98-4CAC-BFC2-BBB79B522DD6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {65C0CC2C-5F10-4F18-9057-176DC70833FA}
Expand Down
39 changes: 39 additions & 0 deletions Tests/Testably.Expectations.Benchmarks/HappyCaseBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using BenchmarkDotNet.Attributes;
using FluentAssertions;
using FluentAssertions.Primitives;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;

namespace Testably.Expectations.Benchmarks;

[MemoryDiagnoser]
public class HappyCaseBenchmarks
{
private readonly bool _boolSubject = true;
private readonly string _stringExpectation = "foo";
private readonly string _stringSubject = "foo";

[Benchmark]
public AndConstraint<BooleanAssertions> Bool_FluentAssertions()
=> _boolSubject.Should().BeTrue();

[Benchmark]
public async Task<bool> Bool_TestablyExpectations()
=> await Expect.That(_boolSubject).Should().BeTrue();

[Benchmark]
public async Task<bool> Bool_TUnit()
=> await Assert.That(_boolSubject).IsTrue();

[Benchmark]
public AndConstraint<StringAssertions> String_FluentAssertions()
=> _stringSubject.Should().Be(_stringExpectation);

[Benchmark]
public async Task<string?> String_TestablyExpectations()
=> await Expect.That(_stringSubject).Should().Be(_stringExpectation);

[Benchmark]
public async Task<string?> String_TUnit()
=> await Assert.That(_stringSubject).IsEqualTo(_stringExpectation);
}
3 changes: 3 additions & 0 deletions Tests/Testably.Expectations.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using BenchmarkDotNet.Running;

BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateProgramFile>false</GenerateProgramFile>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="FluentAssertions" Version="6.12.2" />
<PackageReference Include="TUnit.Assertions" Version="0.2.202" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Source\Testably.Expectations\Testably.Expectations.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=benchmarks/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Loading