Repository navigation
Add ZIO Test integration (difflicious-zio-test) - #350
Draft
Sootopolis wants to merge 2 commits into
Draft
Sootopolis wants to merge 2 commits into
Sootopolis wants to merge 2 commits into
Conversation
Adds a difflicious-zio-test module so ZIO Test users can call differ.assertNoDiff(obtained, expected) in their specs. - assertNoDiff returns a failing TestResult instead of throwing, so it combines with &&, works in for comprehensions, and keeps shrinking in property tests (check). - On the JVM, ZIODiffliciousSpec adds a test aspect that writes a JSONL report for each failed diff, recording the labels of the enclosing suites as the test hierarchy. A root suite named after the spec is left out, since the report already records the spec's name. A diff is reported only when zio-test counts it towards the failure, matching what the console prints. Specs that replace `aspects` can add the aspect back through the protected diffliciousReporting. JS and Native get the assertion only. - A Differ for zio.NonEmptyChunk. Specs that mix in ZIODiffliciousSpec get it without an import; elsewhere it comes from difflicious.ziotest.implicits. - Cross-built for Scala 2.13 and 3 on JVM, JS and Native. - Unit tests, a zio-test-jsonl scripted test, a docs page, and a demo in the example module. - Link Scala.js and Scala Native test programs one at a time, so the full build stays within the 3 GB heap set in .jvmopts. ZIO's test programs are the largest in the build, and overlapping links pushed it out of memory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sbt 2 caches tasks by default. When CI restores sbt's disk cache and the build definition is unchanged, the cached result skips the wait, so the website build can start before all mdoc output files exist and fail with "Invalid sidebar file". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sootopolis
force-pushed
the
zio-test-integration
branch
from
November 1, 2026 21:25
264ae76 to
c508f7c
Compare
Sootopolis
marked this pull request as draft
November 1, 2026 23:58
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds ZIO Test support, following up on our chat after your London Scala talk. It needs no changes to ZIO Test.
What a failure looks like
From the personal project mentioned under "Verification", with expectations broken on purpose. In the test output:
Another failure, in
diffliciousViewer --plain:What's being added
difflicious-zio-testmodule for Scala 2.13 and 3, on the JVM, Scala.js and Scala Native. Reports are written on the JVM only, as with the other integrations.ZIODiffliciousSpec, which gives a specassertNoDiffand reports.Differforzio.NonEmptyChunk, which those specs get without an import.zio.Chunkalready works, as it's aSeq.example.How it differs from MUnit and Weaver
assertNoDiffreturns a failed result instead of throwing, as ZIO Test'sassertTruedoes. Throwing broke two things: property tests (check) stopped shrinking, and inassertTrue(a) && differ.assertNoDiff(x, y)the exception discarded the failure thatassertTruereturned. The cost is ZIO Test's usual one: a result left on a line of its own is ignored (-Wnonunit-statementwarns about it).Reports are written by an "aspect". ZIO Test's
test(...)andsuite(...)just build a tree of values, so there's no suite class to hook into. But a spec can list aspects, which ZIO Test applies to the whole tree before running it.ZIODiffliciousSpecadds one that picks up suite names on the way down and writes a report when a test fails on a diff.The report gets the full path, e.g.
outer / inner / my test, as ScalaTest's do, minus a root suite named after the spec, which the viewer would otherwise show twice.Replacing a spec's
aspectsis common in ZIO code, and doing so drops this one. The test still fails and prints its diff, but no report is written, so the trait exposes it asprotected def diffliciousReportingfor such specs to add back. The docs cover this.Changes to the shared build
Scala.js and Native test programs now link one at a time. With ZIO added, overlapping links took a full
sbt testpast the 3 GB in.jvmopts(master alone was fine). In three cold CI runs of master with and without this setting, the test step took about 7½ minutes either way. Raising the heap instead works too, if you prefer.waitForMdocOutputis no longer cached. sbt 2 caches tasks by default, so when CI restores its cache and the build is unchanged, the wait is skipped and the website build can fail with "Invalid sidebar file". I reproduced it on master in my fork's CI by re-running a passed build (log). This has nothing to do with ZIO, so I can move it to its own PR if you prefer.Verification
sbt 'zioTest3/test; zioTest/test'sbt 'sbtPlugin/scripted difflicious/zio-test-jsonl'sbt scalafmtCheckAllNo tests were executedor a low test count. That's azio-test-sbtlogging bug on passing runs, not skipped tests: a deliberately failing assertion on Native fails the build.Left out for now
These can follow if you'd like them:
assertNoDiff. As with MUnit and Weaver, it needs the trait mixed in.zio-json,zio-httpandzio-prelude, which would need their own modules.Generated with Claude Code