# 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 account and no network. `osyrin dev` starts the platform; your editor launches the debugger through `osy debug-test`.

<!-- id: testing-debugging-tests-locally · area: testing · stability: stable · html: https://osysharp.com/reference/testing/debugging-tests-locally/ -->

## Summary        {#summary}

Debugs a single test against a Platform running on your own machine. You set a breakpoint in a test, launch the
debugger from your editor, and the run pauses where you asked — with the call stack, the current line, and your
variables all inspectable. It is the debugging counterpart of [Running tests locally](https://osysharp.com/reference/testing/running-tests-locally/): same local platform,
same throwaway-copy isolation, same enforced security — you are simply watching one test run under a debugger instead
of reading a pass/fail report.

## Signature      {#signature}

```osy syntax
osy debug-test --test <id> [path]
```

## Description    {#description}

### Debug from your editor   {#editor}

With a local platform running (`osyrin dev`), open a test file in an editor that has the Osy# extension, set a
breakpoint on a line inside a `[Test]`, and start debugging. The editor launches the debugger for you and drives the
session; `osy debug-test` is the command it runs behind the scenes to reach the local platform. As with
[Running tests locally](https://osysharp.com/reference/testing/running-tests-locally/), there is nothing to log into and nothing to deploy — it finds the running local
platform for your project, ensures your app exists there, compiles the source on your disk, and debugs against that.

### One test at a time   {#one-test}

A debug session runs exactly one test, named by its id (`file::fixture::name`) — the same id
[Running tests locally](https://osysharp.com/reference/testing/running-tests-locally/) uses with `--test`. That is why the flag is `--test <id>` and not repeatable: a
debugger pauses inside one test, not across a suite. Pick the test in your editor's test view, or pass its id.

### The test runs exactly as it would anywhere   {#parity}

Debugging is not a weaker mode. Your app's own security is enforced just as in production: a `[Test]` runs as an
anonymous, secured caller, so a test that reads or creates data needs your model to grant it. The test runs in its own
throwaway clone that is discarded when the session ends — nothing it writes survives, and your real data is never
touched. See [Running tests](https://osysharp.com/reference/testing/running-tests/) for the full model.

### Debugging against a remote platform   {#remote}

The same gesture works against a deployed app with `osyrin app debug-test --test <id>`. It is the remote twin of this
command, exactly as [Running tests](https://osysharp.com/reference/testing/running-tests/) is the remote twin of [Running tests locally](https://osysharp.com/reference/testing/running-tests-locally/) — the only
difference is which platform it reaches.

## Examples       {#examples}

Start a local platform, then debug one test from your editor (which invokes the command for you):

```console
# terminal 1
osyrin dev
```

```osy title="the model — behaviour on a class, so it can be stepped" test app=testing-debugging-tests-locally
// model/order.osy — behaviour lives on a class, so it can be stepped through.
class Order {
  public decimal Total;
  public void AddLine(decimal amount) { Total = Total + amount; }
}
```

```osy title="the test, and the line to put the breakpoint on" test app=testing-debugging-tests-locally
// tests/orders.test.osy
[Test]
void Totals_Add_Up() {
  var order = new Order { };          // ← set a breakpoint here, then start debugging
  order.AddLine(20);
  order.AddLine(5);
  Assert.Equal(25, order.Total);
}
```

The equivalent invocation the editor makes:

```console
osy debug-test --test "tests/orders.test.osy::Seeded::Totals_Add_Up"
```

## See also       {#see-also}

[Running tests locally](https://osysharp.com/reference/testing/running-tests-locally/) — run your tests locally without a debugger, and the full description of the local
platform, isolation, and enforced security.

[Running tests](https://osysharp.com/reference/testing/running-tests/) — the same run against a remote platform.
