# Testing in the Swift SDK (/reference/swift-sdk/testing)

Test a Swift app against a fake working copy and an in-memory keychain, with no server.



`WorkingCopy.fake(items:edges:itemTypes:edgeTypes:views:displays:linkCandidates:)` from `MarfaTesting` returns a `FakeCopy`. **Its `copy` is a real `WorkingCopy`** over an in-memory engine, so argument checks, the change feed and value conversion are the app's own.

```swift
#if DEBUG
import MarfaTesting

let fake = WorkingCopy.fake(items: [note], itemTypes: [noteType])
let model = NotesModel(copy: fake.copy)
#endif
```

The fake answers item, edge, tag, metadata and extension reads and writes, `search`, view reads and writes, the whole queue, `changes()` and `updates()`. **Tables are never held.** **A call or input it can't match exactly throws `FakeCopyError.unsupported(call:)`:** a `filter`, `changes(since:most:)`, `counts`, body links, hydration, files and folders, other table calls, and `declareTypes(_:)` with status words. It knows only the types given and declared. **A row it makes is at version 0 until a drain takes its create.** It makes and checks item IDs as [`ItemID`](/reference/swift-sdk/items#make-an-items-id) does, and takes `email`, `date` and `datetime` members in a list entry.

**The fake never fills a write's `answer`:** decide from its `verdict`. A conflicted edit keeps the server's value in the fields the verdict names, and the fake makes no conflicted copy.

| Member | Does |
| - | - |
| `verdict` | Chooses each write's verdict at a drain. The default accepts; `nil` leaves it unanswered. A write behind a refused one is refused unsent. |
| `writes` | Every write received, in order, with its verdict. |
| `landedCreates` | IDs of items the server holds though their creates are blocked or dead. A `withdraw` of such a create shows the item at version 1. |
| `answeredCreatedAt` | Names the creation time the server's answer to a sent create would carry. An edit with `clearOccurredAt` on an item whose create was already sent needs it. Without it, that edit throws `unsupported`. |
| `displays`, `linkCandidates` | Script `displays(for:)`, `displays(of:)` and `linkCandidates(of:in:)`. Unscripted, they throw `unsupported`. |
| `send(_:)`, `sendUpdate(_:)` | Tell every `changes()` stream a change, or every `updates()` sequence a `CopyUpdate`. |

`MemoryKeychain()` is a keychain in memory for tests: give its `keychain` to `KeychainKeyStore`, `Authorization` or `Server`. `failReads(with:)`, `failWrites(with:)` and `succeed()` act as a locked keychain, `reads` counts its reads, proving a call read none, and `signIn(to:service:accessToken:refreshToken:scopes:)` keeps a sign-in with no browser. `MemoryKeyStore([URL: String])` is a `KeyStore` in memory.
