Skip to main content
By default, hitspec executes requests in the order they appear in the file. The @depends directive lets you declare explicit dependencies between requests, ensuring that prerequisite requests run first regardless of file order.

Basic Usage

Add # @depends <requestName> to any request that relies on another:
The getProfile request will always execute after login, even if you run tests in parallel mode or filter to a specific request.

Multiple Dependencies

A request can depend on multiple other requests. Separate names with commas:
All listed dependencies must complete before the dependent request runs. The dependencies themselves can run in any order (or in parallel, when --parallel is enabled).

How It Works

Topological Sort

hitspec builds a directed acyclic graph (DAG) from the @depends declarations and performs a topological sort to determine execution order. This means:
  • Dependencies always run before the requests that need them
  • Independent requests can run in any order
  • With --parallel, independent requests run concurrently
Given this dependency graph:
hitspec determines that login and setupDb can run in parallel, getProfile and createPost must wait for their dependencies, and verifyPost runs last.

Cycle Detection

hitspec detects circular dependencies at parse time and reports an error:
This produces an error:
Circular dependencies are always a configuration error. Restructure your tests so the dependency chain flows in one direction.

Cross-File Dependencies

Dependencies work across files within the same test run. If login is defined in auth.http and createPost in posts.http, you can still declare:
As long as both files are included in the test run:

Implicit Dependencies via Captures

Using a captured variable implicitly requires the capturing request to run first, but hitspec does not infer this automatically. You must always declare @depends explicitly:
Without @depends, hitspec may execute requests in any order (especially with --parallel), causing captured variable references to resolve to empty strings.

Dependency Chains

Dependencies are transitive. If A depends on B and B depends on C, then A implicitly waits for both B and C:
You do not need to write # @depends createOrg, createTeam on addMember — depending on createTeam is sufficient because createTeam already depends on createOrg.

Parallel Execution with Dependencies

When you run tests with --parallel, hitspec respects all @depends constraints while maximizing concurrency for independent requests:
In this mode:
  • Requests with no dependencies start immediately
  • Requests with satisfied dependencies start as soon as their prerequisites complete
  • The --concurrency flag limits how many requests run simultaneously

Filtered Execution

When you filter tests by name or tag, hitspec automatically includes any dependency that the filtered request needs:

Common Patterns

Setup and Teardown

Fan-Out Pattern

Multiple requests depend on a single setup step:
With --parallel, the three test requests run concurrently after login completes.
Last modified on February 9, 2026