Skip to content

feat: add WithoutMessage for delegate assertions#793

Merged
vbreuss merged 2 commits intomainfrom
topic/add-withoutmessage
Sep 19, 2025
Merged

feat: add WithoutMessage for delegate assertions#793
vbreuss merged 2 commits intomainfrom
topic/add-withoutmessage

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Sep 19, 2025

This PR adds new WithoutMessage methods for delegate assertions, providing the ability to verify that thrown exceptions do not have specific messages or message content. The feature enhances the exception assertion API by providing negative assertions for message validation.

Key changes:

  • Added DoesNotHaveMessage and DoesNotHaveMessageContaining methods for exception assertions
  • Added WithoutMessage and WithoutMessageContaining methods for delegate exception assertions
  • Updated error message formatting to be more consistent and include contextual information

@vbreuss vbreuss self-assigned this Sep 19, 2025
Copilot AI review requested due to automatic review settings September 19, 2025 14:01
@vbreuss vbreuss added the enhancement New feature or request label Sep 19, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds new WithoutMessage methods for delegate assertions, providing the ability to verify that thrown exceptions do not have specific messages or message content. The feature enhances the exception assertion API by providing negative assertions for message validation.

Key changes:

  • Added DoesNotHaveMessage and DoesNotHaveMessageContaining methods for exception assertions
  • Added WithoutMessage and WithoutMessageContaining methods for delegate exception assertions
  • Updated error message formatting to be more consistent and include contextual information

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Source/aweXpect/That/Exceptions/ThatException.HasMessage.cs Added DoesNotHaveMessage method and updated constraint implementation
Source/aweXpect/That/Exceptions/ThatException.HasMessageContaining.cs Added DoesNotHaveMessageContaining method and updated constraint implementation
Source/aweXpect/That/Delegates/ThatDelegateThrows.WithMessage.cs Added WithoutMessage method for delegate assertions
Source/aweXpect/That/Delegates/ThatDelegateThrows.WithMessageContaining.cs Added WithoutMessageContaining method for delegate assertions
Tests/aweXpect.Tests/Exceptions/ThatException.DoesNotHaveMessage.Tests.cs Comprehensive test coverage for new DoesNotHaveMessage functionality
Tests/aweXpect.Tests/Exceptions/ThatException.DoesNotHaveMessageContaining.Tests.cs Comprehensive test coverage for new DoesNotHaveMessageContaining functionality
Tests/aweXpect.Tests/Delegates/ThatDelegate.ThrowsException.WithoutMessage.Tests.cs Test coverage for delegate WithoutMessage method
Tests/aweXpect.Tests/Delegates/ThatDelegate.ThrowsException.WithoutMessageContaining.Tests.cs Test coverage for delegate WithoutMessageContaining method
Docs/pages/docs/expectations/06-delegates.md Updated documentation with examples of new methods
Multiple test files Updated expected error messages to include additional context information

Comment thread Source/aweXpect/That/Exceptions/ThatException.HasMessage.cs
Comment thread Source/aweXpect/That/Exceptions/ThatException.HasMessage.cs
@vbreuss vbreuss enabled auto-merge (squash) September 19, 2025 14:08
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 19, 2025

🚀 Benchmark Results

Details

BenchmarkDotNet v0.14.0, Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 8.0.414
[Host] : .NET 8.0.20 (8.0.2025.41914), X64 RyuJIT AVX2

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Bool_aweXpect 228.1 ns 0.99 ns 0.77 ns 0.0300 - 504 B
Bool_FluentAssertions 245.1 ns 5.57 ns 5.21 ns 0.0567 - 952 B
Bool_TUnit 874.5 ns 13.90 ns 12.32 ns 0.1431 - 2408 B
Equivalency_aweXpect 295,077.7 ns 696.09 ns 581.27 ns 20.0195 0.9766 335556 B
Equivalency_FluentAssertions 2,226,303.9 ns 12,187.23 ns 11,399.94 ns 273.4375 46.8750 4584416 B
Equivalency_TUnit 677,385.0 ns 2,498.30 ns 2,336.92 ns 51.7578 2.9297 880545 B
Int_GreaterThan_aweXpect 261.5 ns 2.74 ns 2.56 ns 0.0486 - 816 B
Int_GreaterThan_FluentAssertions 261.9 ns 2.24 ns 2.09 ns 0.0730 - 1224 B
Int_GreaterThan_TUnit 1,281.6 ns 10.25 ns 9.59 ns 0.1774 - 2984 B
ItemsCount_AtLeast_aweXpect 507.5 ns 3.21 ns 2.84 ns 0.0868 - 1464 B
ItemsCount_AtLeast_FluentAssertions 517.1 ns 3.58 ns 2.99 ns 0.1192 - 2008 B
ItemsCount_AtLeast_TUnit 15,307.2 ns 247.49 ns 231.50 ns 1.6174 - 27480 B
String_aweXpect 474.5 ns 6.67 ns 6.23 ns 0.0734 - 1232 B
String_FluentAssertions 464.8 ns 7.62 ns 7.13 ns 0.1292 - 2168 B
String_TUnit 1,278.1 ns 15.35 ns 14.36 ns 0.1831 - 3072 B
StringArray_aweXpect 1,930.7 ns 10.85 ns 9.06 ns 0.1717 - 2888 B
StringArray_FluentAssertions 1,370.1 ns 16.18 ns 13.51 ns 0.2480 - 4152 B
StringArray_TUnit 3,271.7 ns 37.06 ns 30.95 ns 0.3128 - 5296 B
StringArrayInAnyOrder_aweXpect 2,429.1 ns 43.48 ns 38.54 ns 0.1831 - 3080 B
StringArrayInAnyOrder_FluentAssertions 149,234.9 ns 838.43 ns 743.25 ns 3.4180 - 63787 B
StringArrayInAnyOrder_TUnit 3,806.4 ns 21.46 ns 17.92 ns 0.3853 - 6488 B

@github-actions
Copy link
Copy Markdown
Contributor

👽 Mutation Results

Mutation testing badge

aweXpect

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Total Detected Total Undetected Total Mutants
That/Delegates/ThatDelegateThrows.WithMessage.cs 100.00% 4 0 0 0 2 0 4 0 6
That/Delegates/ThatDelegateThrows.WithMessageContaining.cs 100.00% 4 0 0 0 2 0 4 0 6
That/Exceptions/ThatException.HasMessage.cs 100.00% 21 0 0 0 6 5 21 0 32
That/Exceptions/ThatException.HasMessageContaining.cs 86.05% 37 2 0 4 10 9 37 6 62

The final mutation score is 91.67%

Coverage Thresholds: high:80 low:60 break:0

aweXpect.Core

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Total Detected Total Undetected Total Mutants

The final mutation score is NaN%

Coverage Thresholds: high:80 low:60 break:0

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

Test Results

    14 files   - 24      14 suites   - 24   4m 23s ⏱️ -44s
17 911 tests +19  17 909 ✅ +19  2 💤 ±0  0 ❌ ±0 
50 367 runs  +30  50 365 ✅ +30  2 💤 ±0  0 ❌ ±0 

Results for commit 9d7a849. ± Comparison against base commit 935f53e.

This pull request removes 1568 and adds 1587 tests. Note that renamed tests count towards both.
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message4082f6d3-d6fb-459c-9504-73dbe6fcbbdb")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messageb747d14f-b304-443e-809a-773f6eb445a9")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messaged5b8ae94-bb52-40e2-b892-215792d2f7a6")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message3916c694-a5b9-4e6a-9f3b-9f915c5d9d77")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "messagea950fd22-ed4f-43a8-8bca-1444a32dab17")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "messagee7832bc8-cd2c-4fbc-a2bb-28710af7b56e")
aweXpect.Core.Tests.FailTests ‑ Test_ShouldThrowException(reason: "reason138eb6a9-a8b8-4da0-bc02-ca977f63ce2a")
aweXpect.Core.Tests.FailTests ‑ Test_ShouldThrowException(reason: "reasona256551e-662c-4ef6-884b-109eae21ca3b")
aweXpect.Core.Tests.FailTests ‑ Test_ShouldThrowException(reason: "reasondab3805d-195c-47f3-8510-5066968d8d26")
aweXpect.Core.Tests.FailTests ‑ Unless_ShouldThrowException(condition: False, reason: "reasonc6cf8556-fb51-4548-8d19-008a4c400d5c")
…
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message8c207fa4-645d-4e59-8347-a47b5d2b8703")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messagea1f0bbd8-3887-4dbb-929d-6dada678d387")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messagec31c55e0-e635-4659-ab72-96eca2a72b4d")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message338b768a-e18f-4c5d-9412-6ed2bfd18fe7")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "messaged7d20355-0431-4fa9-a15d-ee001dda8dc0")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "messagee6ddbf34-d678-45c4-9bc0-595d8cafcd22")
aweXpect.Core.Tests.FailTests ‑ Test_ShouldThrowException(reason: "reason1202598a-4fea-450e-8e79-5ed487fcd7ab")
aweXpect.Core.Tests.FailTests ‑ Test_ShouldThrowException(reason: "reason417162fd-660b-4c5d-8e4b-cfcfce4572cc")
aweXpect.Core.Tests.FailTests ‑ Test_ShouldThrowException(reason: "reasondc214b6f-4590-4c89-a73d-0357157fa407")
aweXpect.Core.Tests.FailTests ‑ Unless_ShouldThrowException(condition: False, reason: "reason33630c10-0c7a-40e7-a164-fdfc203adf68")
…

@vbreuss vbreuss merged commit dd79b96 into main Sep 19, 2025
14 checks passed
@vbreuss vbreuss deleted the topic/add-withoutmessage branch September 19, 2025 14:17
github-actions Bot added a commit that referenced this pull request Sep 19, 2025
github-actions Bot added a commit that referenced this pull request Sep 19, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This is addressed in release v2.25.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants