Expand description
Tests that run inside a built Day app (docs/testing.md): a Case is a page plus a drive,
or a headless run, declared next to the code it tests with #[day::test] and collected in a
registry. The dayscript engine runs them on a real toolkit under day test; the mock
harness runs the same functions under cargo test. Nothing here knows how a step is
executed: a DriveBackend does, and the engine supplies one.
A test’s name is its function’s, with hyphens for underscores (button_status runs as
button-status): the registry entry carries the identifier, so a tool reading the source
(day test --list, an editor) and the app agree without either one running the other.
Structs§
- Case
- One test: what it proves, what it needs, the page it shows and the body that drives it.
Built by a
#[day::test]function each time the test runs, so the signals a page and its drive share are fresh per run; the registry names it after that function. - Drive
- The handle a test drives the app with. Every method awaits the op and fails the test with the step’s own message when the op fails after its retry window.
- Fail
- A failed assertion, with the sentence the report shows.
- Frame
Expect - What
Drive::assert_frameexpects of an element’s frame, in points; only the fields set are checked.x/yare relative torelative_to’s origin, or the window content’s. - Native
Expect - What
Drive::assert_nativeexpects the native widget to report; only the fields set are checked (docs/testing.md). - TestFn
- A registered test: the function that builds its
Case, and that function’s identifier, which is where the test’s name comes from. Declared by#[day::test].
Enums§
- DriveOp
- What a drive asks of the app, in dayscript’s vocabulary. The engine maps each to the step a script would send, so a drive and a script mean the same thing by the same words.
- Test
Kind - Whether a case shows a page and drives it, or runs with no page.
Statics§
- TESTS
- Every native
#[day::test], collected without runtime constructors.
Traits§
- Drive
Backend - Executes
DriveOps. The engine’s backend runs each as the matching dayscript step on the main thread and waits, asynchronously, through the step’s retry window; the mock harness uses the same backend against the mock toolkit.
Functions§
- active
- The active case, for the test host to build.
- announcements
- The announcements made since the run began.
- case_
named - A fresh case for the test called
name, for a person browsing an app’s tests (the conformance app’s navigation does). - cases
- Every registered test as a fresh, named
Case, sorted by name. - clear_
active - Return the test host to the app’s own content.
- intercept_
open_ url - Record
urlif a test run is intercepting; whether it did. - note_
announcement - Record a screen-reader announcement if a test run is going on. Unlike a URL it still goes to the toolkit: announcing has no side effect a run must avoid, and the duty is what a case proves.
- note_
page_ panic - Record a panic the test host caught while building the active case’s page.
- opened_
urls - The URLs opened (and intercepted) since the run began.
- panic_
message - The sentence a caught panic’s payload reads as.
- register
- Add a synthetic case in a test harness. Application tests use
#[day::test]. - set_
active - Show
casein the app’s test host, built fresh, until the next call orclear_active. Answers false when the app mounts no test host, so the runner can say so. - set_
host - Install the mounted test host’s rebuild (
day::test_hostdoes, for the life of its scope);Nonewhen it goes. - set_
intercepting_ urls - Start or end a test run’s interception of
crate::open_url: while it is on, a URL the app asks to open is recorded instead of opened, soassert_opened_urlcan check it and no browser starts on the machine running the tests. - take_
page_ panic - The panic, if any, the active case’s page raised as it was built.
- tests
- Every registered test, link-time and run-time ones together.
- validate_
registry - Fail closed before listing or running compiled tests, independent of test filters.
Type Aliases§
- OpFuture
- The future one drive op resolves to.
- Test
Result - What a test’s body answers.