Repository navigation
v0.15.0
·
22 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
[0.15.0] - 2026-11-15: event ID allowlist, compact dumps with exceptions, .NET 11
BREAKING
LogCapture.Deconstructwas removed, as 0.14.0 announced. It only turnedvar (factory, collector) = LogCollectorBuilder.Create();into a build error that named the new form; that line now fails with the compiler's own error (CS1061, noDeconstructonLogCapture). Source that compiled against 0.14.x never contained the call, so this changes binary compatibility only. Migration:using var logs = LogCollectorBuilder.Create();, thenlogs.Collector(await using varin async code).LogContractRenderer.Renderoutput changed in two cases. Definitions that tie on event ID, name, template, and level used to keep their input order, so the same set could render in two orders; they are now ordered by their rendered line as well. The event name and the placeholder names are now escaped like the template (\\,\", CR, LF, and tab), so a name with a line break no longer splits its line. A committed contract baseline changes only if it held such a tie or such a name. Migration: regenerate the baseline and review the diff.
Added
- Targets
net10.0andnet11.0. Each target framework resolves its ownMicrosoft.Extensions.Diagnostics.Testing(10.11.0 fornet10.0, 11.0.0 fornet11.0). WithEventIdIn(params int[] eventIds)on every assertion chain (HasLogged,HasNotLogged,HasLoggedSequencesteps,WillLog) andLogFilter.WithEventIdIn(params int[] eventIds): records whose event ID is any of the listed IDs, in place ofLogFilter.Any(LogFilter.WithEventId(a), LogFilter.WithEventId(b)). Duplicates count once. An empty list throwsArgumentException, because a filter that accepts nothing is almost always a mistake and would makeHasNotLogged()pass for no reason. The failure text names the call with its distinct IDs and describes the filter asEventId in {1, 2}, with braces, so it is not taken for the range ofWithEventIdInRange.DumpVerbosity.CompactWithException(value 3, appended afterVerbose; the values of the other members did not change): theCompactheadline of each record plus oneexception: Type: messageline for a record that carries an exception, with no properties and no scopes. It works withDumpTo,DumpToTestOutput, and bothDumpToTestOutputOnFailureoverloads; a dump of 46 records, three of them with an exception, is 49 lines.
Changed
TUnit.AssertionsandTUnit.Coreminimum versions raised from 1.81.10 to 1.85.0: 1.83.0 is the first TUnit with anet11.0asset, and 1.85.0 keeps TUnit's OpenTelemetry and ASP.NET Core packages on OpenTelemetry 1.20.x fornet10.0, so a project with one version for all its TUnit packages gets no .NET 11 packages there.- README: the shared-host recipe (build and start a host that outlives a test inside
Task.RunwithinExecutionContext.SuppressFlow()and await it after the block, because suppressing the flow does not clear the calling thread's own context) is in the TUnit adapter README and in the remarks ofAddTeedFakeLoggingas well; the lifetime attribute is needed once in every test assembly, also when the package arrives through another project; a new cookbook entry, "Pin the records other tools read", showsWithEventName(...).WithMessageTemplate(...)for a record the contract renderer cannot reach; the troubleshooting entry for the removedDeconstructnames the new error; every C# sample compiles against the packed packages.
Fixed
- Dumps and failure messages (
DumpTo,DumpToTestOutput,DumpToTestOutputOnFailure, and the captured records in an assertion failure) wrote an exception message with line breaks as several lines, the later ones without indentation. Theexception:line now shows the message on one line, each line break replaced by a space;Verbosestill writes the full exception text below it. - Captured records in failure messages and dumps wrote a captured message, category, property key or value, or scope text that held a line break as several lines, the later ones without indentation, so they could be mistaken for records or detail lines of their own. Each now stays on one line, each line break replaced by a space, as the exception message does.
LogSnapshotRendereris unchanged: it writes the captured text verbatim, as documented. - Filter descriptions and the allowlist (the
matching:andStep filters:clauses of a failure, the filter named by a canceled wait, and theAllowed definitions:lines ofHasLoggedOnly) wrote a substring, key, template, or event name that held a line break as several lines. Each line break is now one space. - Expression text of a failure (
.Containing(...),.WithProperty(...),.WithCategory(...), and the other chain methods that take a string, a value, or a definition) wrote the caller's argument raw, so a line break in it split the expression line and a quote or backslash made it ambiguous. The text now reads as a C# string literal does:\,", CR, and LF are written as\\,\",\r, and\n, and the other line breaks the failure text recognizes (form feed, NEL, LS, and PS) as\f,\u0085,\u2028, and\u2029. HasNotLogged()failure showed only the last 50 captured records, so a matching record older than that was not in the message. When an older match would be hidden, the message now lists the matching records themselves (Matching records (N of M captured):, capped at the latest 50 after a line that counts the earlier ones). When the last 50 captured records hold every match, the message is unchanged.