Skip to content

Add Test.RunnerV2 module - #260

Draft
lydell wants to merge 58 commits into
elm-explorations:masterfrom
lydell:fromTestV2
Draft

Add Test.RunnerV2 module#260
lydell wants to merge 58 commits into
elm-explorations:masterfrom
lydell:fromTestV2

Conversation

@lydell

@lydell lydell commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

This deprecates the Test.Runner module and adds Test.RunnerV2. This is a backwards-compatible change.

node-test-runner PR: rtfeldman/node-test-runner#686. The idea is to require a recent enough version of elm-explorations/test in node-test-runner (updating the package in projects is a no-brainer), but keep compatibility in this package, so we don’t leave elm-test-rs behind.

Changes in Test.RunnerV2:

  • Removed seed distribution. All fuzz tests now run with the same seed. This means that moving a test, adding another fuzz test, or commenting out a fuzz test no longer can cause fuzz tests to behave differently, even though you passed a fixed seed. This also got rid of a lot of complexity.
  • Unit tests and fuzz tests are now returned separately. This allows a runner to more cleverly distribute tests across threads. For example, spread the fuzz tests on multiple threads, while running all unit tests single threaded. This also allowed for more precise types. Previously it looked like you could get a DistributionReport for unit tests, while in practice you can’t, for example.
  • Running tests now collectDebug.log so that they can be displayed together with the test that made them. For unit tests, only the debug logs from the run that caused a fuzz test to fail is collected. (We ignore Debug.log from exploratory runs). Closes Proof of concept: allow Debug.log in fuzz tests #156. Closes capture Debug.log and present it with a failing test #154. Related: Capture Debug.log rtfeldman/node-test-runner#400
  • Running tests now report how long it took to execute.
  • Make it possible for runners to run fuzz tests with the “fuzzer ints” (RandomRun) from a previous failure, allowing for an instant reproduction of a fuzz test failure. Related: Quick way to debug failing fuzz tests rtfeldman/node-test-runner#327
  • There is now a function for identifying tests, making runners no longer need to do surgery on the compiled JS. Closes add downcast test api to help testrunners #200

Comment thread src/Test/Expectation.elm Outdated
Comment thread src/Test/Expectation.elm Outdated

@jfmengels jfmengels left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks very good to me, great work!

I left a bunch of improvement suggestions, but none are blocking.

Comment thread src/Test/Expectation.elm Outdated
Comment thread src/Test/Expectation.elm
Comment thread src/Test/Fuzz.elm Outdated
Comment thread src/Test/Fuzz.elm
Comment thread src/Test/Internal.elm


wrapWithTryCatch : (a -> Expectation) -> (a -> Expectation)
wrapWithTryCatch getExpectation =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is wrapWithTryCatch mostly a rename of what was done before, in order to make it clearer what's happening?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Previously, the thunks weren’t “stored with a try-catch wrapper” (like I changed them to) – instead, when running a test thunk that happened in a try-catch. This doesn’t work with my new, more detailed fuzz test failures, though. Catching errors so late means that it’s much more trouble constructing a FuzzTestFailData. Whereas if we wrap early we get everything for free.

(Not sure if this explanation made sense at all.)

Comment thread src/Test/RunnerV2.elm Outdated
Comment thread src/Test/RunnerV2.elm Outdated
Comment thread src/Test/RunnerV2.elm Outdated
Comment thread src/Test/RunnerV2.elm Outdated
Comment thread src/Test/RunnerV2.elm Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

capture Debug.log and present it with a failing test

2 participants