Osy#betaRun it on Osyrin: osyrin.com

Reference

Testing

28 pages.

Outbound calls in a test

A `[Test]` answers an outbound call from a stub — `Http.<Verb>.Stub(url => …)` — or, when the test says so with `[AllowNetwork("host")]`, makes it…

Stubbing your own functions in a test (fault injection)

`<Function>.Stub(λ)` makes one of the app's own functions answer a value, or throw, for the rest of a `[Test]` — wherever it is called from: the test…

Testing (real app, real data, real rules)

A test in Osy# is not a unit test with the world mocked out. It is your app, running against its own throwaway database, with your security rules…

Testing search by meaning — TestEmbedder.Use and a deterministic embedder

`TestEmbedder.Use(embedder)` makes a test run embed with an embedder written in Osy# — any class implementing `Osysharp.Memory.IEmbedder` — so a…

Assert

The assertions a test makes. Beyond the usual equality and null checks there are comparisons (Greater, Less, InRange), a regex check (Matches)…

Assert.NoTraceOf(token)

The erasure oracle: the token is found nowhere the app keeps data — any column of any table (the audit trail, memory, outboxes, translations and the…

Calling your own MCP tool catalog from a test

`Mcp.*` opens a REAL MCP session against a tool catalog your own app publishes with `app.McpServer`, from inside a `[Test]`, and returns what it…

Calling your own REST API from a test

`Api.*` sends a real HTTP request to a route your own app publishes with `app.Apis`, from inside a `[Test]`, and returns what came back —…

Cost.Mark() and Cost.StatementsSince(mark)

What a test's unit of work sent to the database between two points: take a mark, do the thing, read what it cost — in the numbers a plan's limits…

Debugging tests locally

Debugs one of your app's tests against a Platform on your own machine — breakpoints, stepping, and variable inspection in your editor — with no…

Dev seeds: a fixture you can load into the running app

Mark a [TestFixture] with [DevSeed("label")] and the local dev page (`osy launch --dev`) offers it as a button that loads that fixture's world into…

Fixtures: built once, cloned for every test, and built on each other

A [TestFixture] is built once per run, and every test that names it runs on its own copy of what it left — rows, files and clock. A fixture may build…

Holding a test's world open

Runs one test and, pass or fail, keeps the world it built serving on your machine — its data and its app version — and opens it in your browser…

Layout assertions — is it actually usable on screen?

Every other assertion is about TEXT or STATE, and all of them pass on a screen that is visually broken: a control can be on the page, enabled…

Running tests

Runs your app's tests against a throwaway copy of its database, reporting each test as it finishes. Your local source is what runs, so you never have…

Running tests locally

Runs your app's tests against a Platform on your own machine — no account, no network, no setup beyond a running local platform. `osyrin dev` starts…

TestClock.Advance and TestClock.Set

In a test, moves the run's clock FORWARD by a duration, then lets the next Workflow.Settle fire every workflow timer the jump made due — reminders…

Theme assertions — does the app really look the way the theme says?

A theme was write-only — Theme.Toggle and Theme.Set are both writes, and a token identifier is compile-time style material that never becomes a value…

Ui — drive the app's UI from a test

Drive the real UI from a test: navigate to a route, click what a person would click, and assert on what the screen shows. `Ui.*` does things…

Ui.HoldServer

In a UI test, keeps the server's answers to the page's reads back until `Ui.ReleaseServer()`, so the test can stand on the screen a slow server…

Ui.Tick

In a UI test, fires every `on every` clock armed on the screen once, now, and waits for their bodies — server calls included — so a test can assert…

Workflow.Redeem (answer a callback URL, as nobody)

Answers a link minted by `<Slot>.CallbackUrl()` the way the third party holding it would — anonymously, with no principal of any kind. It is the only…

Workflow.Settle and Background.Settle — let due work run, in a test

Test-only. Workflow.Settle(row) runs that row's workflow until it has nothing left to do now: due timers, reminders, an expired state or deadline…

[AllowNetwork] — a test that calls another machine

A test calls no other machine unless it says so. An outbound call with no stub — `Http.*`, a typed client built on it, an SMTP send — is REFUSED when…

[Test] / [TestFixture]

A test is an ordinary function marked [Test]. It runs against a throwaway clone of the app, so it may create rows and break rules freely. A…

[runas(Name)] test attribute and principal selectors

A test runs deny-all as an anonymous principal, so to read or write real data it must act AS a seeded `[Principal]`. Declare a named selector with…

app.TestClock — pin every test's clock

One line in any `.test.osy` file opts the whole project into a pinned test clock: every test and every fixture then starts at that instant instead of…

runas

Runs a block as a given principal, so security rules apply exactly as they would for that user. It is how you test that a rule denies the people it…