RabbinatixDocs
Sign inGet started

Build behaviour (Flow-Driven Development)

Test data and expected results

Test data stands in for databases, APIs and inputs that don’t exist yet; expected results describe the result you expect.

Open Test data in the app

Why you need them

A flow touches things you may not have built yet: a users database, a payment provider, another team's API. Test data stands in for them with fixed, predictable answers. Expected results say what a good (or a bad) result looks like. Together they let you run the whole flow and get the same answer every time.

Test dataExpected result
Answers"When this input arrives here, return this""Is what came back what we expected?"
Used atA call: an API, a database, queue or external operation, or the flow's inputThe result of a flow, or a step
PageTest dataExpected results
KeyTEST-DATA-USER-DARIUS-001EXPECTED-LOGIN-SUCCESS-001

Create test data

  1. Open Test data under Behaviour in the sidebar and press New test data.
  2. Under Which call?, pick what it answers for. The calls are split into tabs by type, each with a count: Resources (database, queue and service operations such as users.findByEmail), Provider APIs, External APIs (public APIs you subscribe to), Unresolved calls (calls to an API nobody provides yet) and Flow inputs. Only kinds that have something show up. Type in the search box to look across all tabs, and press Enter to pick the first match.
  3. Name it, for example "Active user Alex".
  4. Under WHEN, add conditions on the input. Pick a path such as body.email, an operator and a value. With no conditions, it answers any input, which makes it a fallback.
  5. Under THEN RETURN, write the value to return. You can set a status, Fail with error (for a timeout or a 500) or add a Delay (virtual ms).
  6. Press Save.

Example from contract fills the value from the API's declared response, and Use last run output copies what the last run produced. Write {{input.body.email}} in a value to copy part of the input into the output. The value is checked against the declared shape, and a mismatch shows a warning.

Mark fields such as tokens or password hashes under Secret fields (masked in runs). They are masked in runs, exports and Step data.

Which one answers

When a run reaches a call, all the test data for it whose conditions all match is a candidate. The most specific one wins:

  1. Test data the test case chose for this call always wins, if it matches. If it doesn't match, the test case fails, because it points at the wrong test data.
  2. Otherwise each match scores points: an exact value scores highest, a list, pattern or range scores less, "exists" or "not equals" less still, and "any value" scores nothing.
  3. On a tie, the higher Priority (tie-breaker) wins, then the older test data.
  4. If none match, an API falls back to its provider's logic or an example from its contract. A database, queue or external operation stops the run with "no test data", and Step data offers Create test data from this input.

So you can have one test data entry for email = "alex@example.com" that returns Alex, and a fallback with no conditions that returns null. Asking for Alex gets Alex; anyone else gets nothing.

Would it match? tests an input against all the test data for the same call and explains why each entry was chosen or skipped. The run's Step data panel shows the same: which test data answered and why the others didn't.

Create an expected result

  1. Open Expected results and press New expected result. It shows once the project has a flow: an expected result checks what a flow gives back.
  2. Pick what it checks, usually the flow's output, and name it, for example "Login succeeds".
  3. Under EXPECT, add checks: a path, an operator and the expected value. For example status equals 200, body.accessToken exists, body.error is absent.
  4. Or paste a sample response and press Create checks from an example, then remove what you don't care about.
  5. Press Save.

Operators include equals, exists, is absent, is null, is not null, has type, matches pattern, in range, contains, does not contain and matches shape. Try against a sample tries the checks before you use them.

How logic and test cases use them

  • In a flow run or a logic's Test tab, every database, queue, external and API call that isn't answered by real logic is answered by test data. The run records which one.
  • In a test case, the input can be flow input test data, and you can choose test data for each call to force a situation, such as "unknown user" or "card declined". The expected result is one of your expected results.
  • In the logic editor, a call step's details list the test data for it and let you add more.

At the end of a run, every check is run and shown, failing ones first, as a list of path, expected and actual. See Test cases and runs.

TipTag test data, for example happy-path or declined, and search the library by tag.