Creating a test project

in Japanese(日本語)

A test project (TestProjects/<name>/) bundles scenarios, profiles and reports for one app. This page covers the project layout and the commands that manage it.

Layout

TestProjects/SampleApp/
├── profiles/
│   ├── apps/ios-app.json          # app profiles (created by /fleetest-profiles = `profile setup`; none right after create)
│   └── runs/ios-run.json          # run profiles (created by `profile setup`; app + device list, each naming its machine + run-time settings)
├── scenarios/                     # Swift DSL
│   ├── _Main.swift                # delegates to the runner (do not edit)
│   └── _disabled/                 # excluded from compilation (parking spot for generation
│                                   # failures and anything you want to keep out of the build)
├── reports/                       # per-scenario Markdown reports
├── results/                       # run-result JSON database (see results_analysis.md)
└── .fleetest/                      # locator fingerprints and other per-project state

Each project maps to its own SPM target fleetest-scenarios-<name>, so a compile error in one project does not stop the others. _Main.swift wires the target to the scenario runner and normally does not need editing.

Two package configurations

There are two ways this project's Package.swift can reference fleetest:

fleetest init scaffolds the external configuration (a Package.swift plus a first test project). With --no-project it creates no project: only the Package.swift and an empty TestProjects/ (the installation uses this; the project1 project is created later by /fleetest-profiles or the VSCode extension; --no-project cannot be combined with --name). --fleetest-path points at a local clone (.package(path:)); --fleetest-url depends on a git URL instead (--fleetest-branch selects the branch to track; it defaults to main).

Managing projects

Command Description
fleetest project create <name> Scaffold a new test project and register it in Package.swift (writes no profiles; create them with /fleetest-profiles)
fleetest project list List test projects and whether they are registered in Package.swift
fleetest project sync Regenerate the Package.swift marker section from a scan of TestProjects/ (run this after a manual copy or a git pull)
fleetest project copy <source> <newName> Duplicate a project under a new name and register it in Package.swift. Excludes run artifacts and caches (reports/, results/, .fleetest/) so the copy starts clean
fleetest project rename <oldName> <newName> Rename a project's directory and update Package.swift
fleetest project lint-selectors [--project <project>] [--contract <contract>] Check for drift between the #id selectors in scenarios and the contract (ui-contract.md) (only #id; labels are excluded because localisation makes them vary). --contract defaults to TestProjects/<name>/docs/ui-contract.md (an error if missing)
fleetest project delete <name> --yes Move a project's directory to the Trash (not permanently deleted) and remove it from Package.swift. --yes is required — omitting it deletes nothing

Package.swift's marker section (between // === fleetest projects begin/end ===) is fully regenerated by create/sync; do not hand-edit it.

Adding dependencies for your scenarios

Scenarios can import system modules such as Foundation, and FTDSL, as they are. To use any other Swift package, or a target of your own shared by several projects, write it in two places in Package.swift:

  1. Add the package itself to the dependencies: of Package (the usual SwiftPM way).
  2. Add the dependency to fleetestScenarioDependencies, keyed by the name of the project that uses it.
let fleetestScenarioDependencies: [String: [Target.Dependency]] = [
    "myapp": [
        .product(name: "SwiftOTP", package: "SwiftOTP"),
        "SharedHelpers",                 // a target of your own defined in the same Package.swift
    ],
]

let package = Package(
    ...
    dependencies: [
        .package(path: "../fleetest"),
        .package(url: "https://github.com/<owner>/SwiftOTP", from: "<version>"),
    ],
    ...

fleetestScenarioDependencies is outside the marker section, so create/sync do not rewrite it (create / sync add an empty declaration to a Package.swift that does not have one). A key that does not match a project name means its dependencies are not used, so sync warns about it.

The build of the dependencies you add (including macros and build plugins) runs outside the scenario sandbox. Add only packages you trust.

Project name rules

A project name becomes an SPM target name, so it must match ^[A-Za-z0-9_][A-Za-z0-9_-]*$ (no Japanese). This restriction is on the project name only — @TestClass class names inside scenarios can be Japanese, as in the examples throughout this documentation.

Resolving --project

Most commands accept --project <name>. When it is omitted, the tool resolves it as follows:

  1. If TestProjects/ contains exactly one project, use it.
  2. Otherwise, fall back to the configured default project.
  3. Otherwise, use the project named project1 if there is one.
  4. Otherwise, fail with a list of candidate project names.

The project1 project

When the VSCode extension starts, it creates TestProjects/project1/ with fleetest project create project1 if it is missing (or empty), and selects project1 initially while fleetest.project is empty. It is a ready-made place for your first scenarios (it has no scenarios or profiles yet; create the profiles with /fleetest-profiles or fleetest profile setup). To work in a project you created under another name, switch with the "Select project" command or the fleetest.project setting.