Skip to content

feat: generate collection expectations with [GenerateCollectionExpectation] - #1834

Merged
vbreuss merged 1 commit into
mainfrom
feat/generate-collection-expectation
Oct 16, 2026
Merged

vbreuss merged 1 commit into
mainfrom
feat/generate-collection-expectation

Conversation

@vbreuss

@vbreuss vbreuss commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

A predicate marked with [GenerateExpectation] only verifies a single subject, so verifying the items of a collection still needed ComplyWith or a hand-written QuantifiedCollectionConstraint. [GenerateCollectionExpectation] generates the expectation on the elements that a quantifier selects from the same kind of method, e.g. That(tracks).All().AreRadioFriendly().

  • it takes the expectation text on a single item and its plural, as a nested expectation reads "has values of which at least 2 are radio friendly"; the quantifier carries the negation
  • it extends the elements of every collection that can hold the item: IEnumerable<T>, struct collections like ImmutableArray<T> and, where available, IAsyncEnumerable<T>, with the string elements for a string item
  • a null item does not match unless the item parameter is nullable, with [DisallowNull] and NullableOverload working like for a subject
  • the generated constraints derive from the new GeneratedCollectionConstraint and GeneratedAsyncCollectionConstraint in aweXpect.Core

The build scope is set to CoreOnly, because the generator tests compile the generated code against the new base constraints of aweXpect.Core. Under that scope the generator tests now run with coverage reports next to the Core tests, as the coverage of the generator was missing otherwise.

@vbreuss vbreuss self-assigned this Oct 16, 2026
@vbreuss
vbreuss added this pull request to stack #1837 October 16, 2026 06:18
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

    20 files   -      71      20 suites   - 71   1h 17m 20s ⏱️ - 45m 24s
 6 111 tests  -  31 612   6 111 ✅  -  31 612  0 💤 ±0  0 ❌ ±0 
39 146 runs   - 180 127  39 146 ✅  - 180 127  0 💤 ±0  0 ❌ ±0 

Results for commit ba36d8b. ± Comparison against base commit 2bdfbc6.

This pull request removes 32109 and adds 388 tests. Note that renamed tests count towards both.

	
	    get;
	"a": 1
	await
	{
	}, 1)


, 2)

, 3)
…
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(57d24b2d-5893-4e5b-8d52-5a771d0d84ea)
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(78b5495b-e870-4aa6-91ca-1fe7ae5d290f)
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(7e292edc-fe95-43d4-9b28-fabbeb6b9f0a)
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(7eed2fc3-75f9-4519-b6a1-144a38968f19)
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(c8748650-baa5-4fa6-883f-9ce3e584a8d2)
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(d414724e-1a3b-4de7-89ca-2e70294697a4)
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ InnerException_ShouldBeSet(fb5576ea-ccf4-4a95-8da1-242d535e6fe7)
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(1ad8513b-eb88-434a-a652-7389886a1205)
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(3d1928e1-74ad-4e00-940e-dfe5467ef733)
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(73126075-e465-4abc-ba38-478daa982fca)
…

♻️ This comment has been updated with latest results.

@vbreuss
vbreuss force-pushed the feat/generate-collection-expectation branch from 81b1e07 to a202f9c Compare October 16, 2026 07:02
…tation]`

A predicate marked with `[GenerateExpectation]` only verifies a single subject, so verifying the items of a collection still needed `ComplyWith` or a hand-written `QuantifiedCollectionConstraint`. `[GenerateCollectionExpectation]` generates the expectation on the elements that a quantifier selects from the same kind of method, e.g. `That(tracks).All().AreRadioFriendly()`.

- it takes the expectation text on a single item and its plural, as a nested expectation reads "has values of which at least 2 are radio friendly"; the quantifier carries the negation
- it extends the elements of every collection that can hold the item: `IEnumerable<T>`, struct collections like `ImmutableArray<T>` and, where available, `IAsyncEnumerable<T>`, with the string elements for a `string` item
- a `null` item does not match unless the item parameter is nullable, with `[DisallowNull]` and `NullableOverload` working like for a subject
- the generated constraints derive from the new `GeneratedCollectionConstraint` and `GeneratedAsyncCollectionConstraint` in aweXpect.Core

The build scope is set to `CoreOnly`, because the generator tests compile the generated code against the new base constraints of aweXpect.Core. Under that scope the generator tests now run with coverage reports next to the Core tests, as the coverage of the generator was missing otherwise.
@vbreuss
vbreuss force-pushed the feat/generate-collection-expectation branch from a202f9c to ba36d8b Compare October 16, 2026 07:02
@sonarqubecloud

Copy link
Copy Markdown

@vbreuss
vbreuss merged commit 409c704 into main Oct 16, 2026
16 checks passed
@vbreuss
vbreuss deleted the feat/generate-collection-expectation branch October 16, 2026 07:43
@github-actions

Copy link
Copy Markdown
Contributor

This is addressed in release v3.3.0.

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

Labels

state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant