Docs/Suites and schedules
#

Suites and schedules

Group tests into suites, run them on demand and in CI, and put them on a schedule with alerts.

Set up a suite, CI and a nightly schedule

A suite is a group of tests that you run together and judge as one. You can run it by hand, from CI on each change, and on a schedule, and the same tests run each way.

Build and run a suite

  1. Put your tests in Regression. Regression is your default suite. A test in it starts running automatically once it has passed once. You can also tag tests to pick out a smaller group, like smoke.

    bash
    cofactor workflow list --search "checkout"
    cofactor workflow add-to-regression <workflow id>
    cofactor workflow patch <workflow id> --tags-add smoke
    
  2. Make a named suite when order matters. A named suite arranges tests into layers. Tests in the same layer run in parallel, and layers run top to bottom, so a sign-in test can finish before the tests that need it.

    bash
    cofactor test-suite create --name "Checkout" --failure-mode continue
    cofactor test-suite set-members "Checkout" --layer "Sign in" --layer "Add to cart,Pay"
    

    Each --layer takes test names or ids, separated by commas. The command replaces all members, so add --yes when the suite already has members. The CLI numbers layers from 0, and the app numbers them from 1.

    The suite builder with one test in layer 1 and two tests in layer 2, and an empty staging area on the left.
  3. Run it on demand. The command streams each test's result.

    bash
    cofactor test-suite run --suite "Checkout"
    cofactor test-suite run --tag smoke
    

    The run prints a pass count. To get the execution id, add --verbose to run, or list recent runs with cofactor test-suite executions.

    It exits 0 when no test failed, 1 when any test failed, timed out or was canceled, and 2 when nothing failed but a platform error meant some tests never ran. CI can tell a product bug from an outage by that code.

  4. Run it in CI. An organization admin creates a key with only the scopes the job needs. The command prints the secret once. Paste it straight into your CI's COFACTOR_API_TOKEN secret, and don't paste it into chat or a file. Add --expires-at so the key does not last forever. The CLI uses it without a login. Running tests against a pull request's preview needs the Scale plan. See Plans and limits.

    bash
    cofactor api-key create --name "CI test runs" --scope test-run:run --scope test-run:read
    
    yaml
    name: cofactor
    on:
      pull_request:
      push:
        branches: [main]
    jobs:
      tests:
        runs-on: ubuntu-latest
        env:
          COFACTOR_API_TOKEN: ${{ secrets.COFACTOR_API_TOKEN }}
        steps:
          - run: npm install -g @runcofactor/cli
          - run: cofactor test-suite run --suite "Checkout"
    

    A failing test fails the step, so it blocks the merge when you require the check.

  5. Put it on a schedule. A nightly run catches drift that changes alone miss, such as an expired credential or a third-party change.

    Open Suites, then Schedules, and select New schedule. Pick the Suite: Regression (add Only tests tagged to run just a tag) or a named suite. In Describe when, type the days, such as "every weekday". Leave it empty to run every day. Pick the Hour, Minute and Time zone. Save schedule stays disabled until you pick a time. Select Save schedule. Each row has buttons to edit, pause, run now and delete.

  6. Send failures to your team. Attach an alert to the schedule. It fires on failure by default.

    Open Suites, then Alerts, and select New alert. Under Applies to, pick One schedule and choose the schedule. Under Destination, pick Email, Slack or Microsoft Teams and the channel or addresses. When is Failures only unless you pick Every run. Select Save alert.

    If Slack is not connected yet, an organization admin runs cofactor slack connect and approves it in the browser. For a private channel, invite the Cofactor app to it. Use --email you@example.com to send email instead.

Check it worked

bash
cofactor test-suite get <execution id>
cofactor schedule suite list --json
cofactor schedule suite runs <schedule id>

The execution lists every test with its result, and the schedule shows its nextRunAt. Add --failures-only to test-suite get to see only the failures. An alert on failure sends nothing for a green run. To test delivery, run cofactor schedule suite run <schedule id> while one of its tests fails. After a red run, cofactor triage wait latest groups the failures by cause. With an API key, triage commands need a key with the * scope.

A suite run with all three tests passed. The summary shows a 100% pass rate, who started the run and the suite name.

Go deeper

Advanced

Why a test was left out, failure mode, pinned runs and cron schedules.

Tests that don't run. A suite leaves out a test that is paused, blocked, under construction or deprecated, and one that is degraded. A test in Regression also waits for its first pass. Each skipped test comes with the reason. Edit or re-enable a degraded test to bring it back.

Failure mode. continue runs every layer even after a failure. stop_on_layer_failure skips later layers when a layer fails. Set it with cofactor test-suite update "<suite>" --failure-mode stop_on_layer_failure.

One environment. --environment staging --env-mode force runs every test against one environment. By default each test uses its own preferred one.

Pinned runs. --at <sha> runs a named suite on a commit of your application. For an application built from an image, use a push id or tag. On a schedule, --at is a time of day instead. A pinned run never feeds visual baselines.

Undo. Delete the schedule first with cofactor schedule suite delete <schedule id>, then the suite with cofactor test-suite delete "<suite>" --yes. Remove a tag with cofactor workflow patch <id> --tags-remove smoke.

Cron and pause. Use --cron "0 3 * * *" or --schedule "every weekday at 9am" instead of --at. cofactor schedule suite pause <id> and resume <id> stop and restart a schedule. The default time zone is UTC.