Zero Unit Testing
The purpose of this series was to explore the idea maze of what the web might look like if it were rebuilt from first principles given the internet infrastructure we have today. The goal was to force clarity to a mess of unrefined ideas by putting them into words as a new essay each month of 2024. Afterward came implementation and not every idea survived first contact with reality. Even the names themselves changed: XUI became Web4, HTTP/X became Keyholes, and ZeroScript became XTML (ironic considering the "zero theme" of the series). This work eventually led to the formation of The Web4 Foundation.
Unit testing
Unit testing is an effective way to validate and enforce expected logic.
Call a method with a given set of inputs.
Assert its expected output.
Makes sense. Except, web4 projects have a problem – its view-models have no methods and its event handers have no return values. Attempting to fit traditional unit testing into such a project would immediately feel pointless.
This isn’t doing anything productive. It’s just a developer typing their inputs twice.
Delta testing
In reactive UI development, the output isn’t a value that comes from a method and it isn’t a primitive whose value can be asserted. Instead, the output is the UI that you see. Some testing frameworks make an attempt to capture rendered markup and assert the presence or absence of certain substrings but there’s a better way.
Embrace the fully rasterized bitmap as a 2-dimensional un-assertable value and just fail the test if it ever changes. Our source control, git, is already fantastic at detecting changes so the act of committing a bitmap to source control is a statement of correctness.
Both Xcode and Android Studio have wonderful support for UI previews. Web4 will simply take the same concept but also make this a fundamental part of the testing framework. All previews will be output to disk and become a part of the source control. Any code changes that result in slight changes to any preview will be detected by git and need to be re-committed before the “delta test” will pass again.