Docs/Setup, seed and teardown
#

Setup, seed and teardown

Reference for test data in Cofactor E2E tests. Seed flows and Seed Data nodes, seed outputs, teardown flows, scope, execution mode and deprecated setup flows.

A seed flow provisions data that several tests share, and a teardown flow removes it. A Seed Data node in a test pulls the seed's outputs in as variables. Data that only one test uses is better created inside that test. For logins and seed data in a sandbox, see Seed data and logins.

Flow types

TypeWhat it is
seedCreates data and exports named values for tests.
teardownCleans up after a seed. A seed links to one teardown flow.
setupDeprecated. See Setup flows are deprecated.

Create these from the E2E tests list. Open the Seeds or Teardowns tab and select New seed or New teardown. A new seed also creates a paired teardown flow named Teardown: <seed name>. From the CLI:

bash
cofactor workflow seed create --name "Create Client" \
  --output client_id:"Client id" --output client_name:"Client name"

Each --output is key:name or key:name:description. Add --no-teardown to skip the paired teardown. To change an existing flow's type, run cofactor workflow patch <workflow id> --flow-type seed.

Seed outputs

A seed flow declares the values it exports. Each output has a Name, a Data Key and an optional Description. A test reads an output as $var.<data key>, for example $var.client_id. See Macros and variables.

To sign in as a user the seed creates, turn on Provisions a credential on an output. Then set the Login node's Credential Source to From seed script and pick that output. That option appears when a Seed Data node comes before the Login node.

The Seed Data node

nodeType: seed. Label: Seed Data.

FieldconfigJson keyNotes
Seed ScriptseedWorkflowIdThe seed flow to run.
VersionsnapshotVersionPins a published version of the seed. null is Live (latest definition).
Execution ModeexecutionModeRecommended (API when available) is recommended. API Only is api. Browser is browser.
API call timeout (seconds)apiTimeoutSecondsDefault 120. Ignored in browser mode.
When to runscopeSee the next table.
Continue on failureonFailureUnchecked is block (default): a failed seed skips the test. Checked is warn: the test continues.
Run teardownrunTeardownOn by default. Shown when the seed has a teardown flow.
When to runscopeBehavior
Each test (before every test that uses it)inlineThe default. The seed runs again for each test.
Once per suite (before all layers)suiteThe seed runs once and every test in the suite shares its outputs. Teardown runs once at the end.
Once per layer (before its layer)layerThe seed runs before the layer that uses it, and its teardown runs right after that layer. Outside a suite, it acts like inline.

To force suite scope for every test that uses a seed, run cofactor workflow patch <seed id> --run-once-per-suite true.

With Recommended, Cofactor uses the seed's API sequence when it has one, and a browser session otherwise. See API sequences.

Teardown

A teardown flow cleans up what its seed created. A fatal assertion failure halts the run, so cleanup steps at the end of a test do not run after it. Use a teardown for anything that must not be left behind.

  • Run teardown on the Seed Data node turns it off for one test.
  • A wait in a seed or teardown flow is limited to 5 minutes.

Seed Data catalog

In Applications & environments, select Applications, then Seed Data. Each seed has a card with View Flow, View Teardown and a Teardown switch. If the seed has no teardown, the card shows Add Teardown.

Setup flows are deprecated

A setup flow, and the Setup Flow node (nodeType: setup) that calls it, ran another flow as a prerequisite. Do not create new ones.

NeedUse
Shared dataA seed flow.
Tests that must run in orderSuite layers.
A reusable step in the middle of a testA Run a flow node.

Rules for test data

  • Create what a test changes, with a unique name, for example QA Test $RANDOM_STRING(6) or $EMAIL(), so reruns do not collide.
  • Seed only what several tests share.