---
title: "5. Testing Scrypto Blueprints"
path: "/developers/scrypto/05-testing-scrypto"
version: "1.5.0"
author: "Hydrate"
createdAt: "2026-02-19T06:11:26.645Z"
updatedAt: "2026-07-27T17:54:25.521Z"
---

# 5. Testing Scrypto Blueprints

<Infobox>
| Key Tools | `[scrypto](/developers/scrypto/01-fundamentals)`, `resim`, `scrypto-test` |
</Infobox>

## Introduction

Once your [development environment](/developers/getting-started/01-install-scrypto) is set up, the next step is understanding the [Scrypto](/developers/scrypto/01-fundamentals) development workflow: creating packages, writing [blueprints](/contents/tech/core-concepts/blueprints-and-packages), building to [WebAssembly](https://webassembly.org), and testing locally. Radix provides two complementary testing approaches — the `resim` simulator for interactive exploration and the `scrypto-test` framework for automated testing.

## Package Structure

A [Scrypto](/developers/scrypto/01-fundamentals) package is a standard Rust crate with [Scrypto](/developers/scrypto/01-fundamentals)-specific dependencies. When you run `scrypto new-package my-dapp`, you get:

```
my-dapp/
├── Cargo.toml          # Dependencies (scrypto crate)
├── src/
│   └── lib.rs          # Blueprint definitions
└── tests/
    └── lib.rs          # Test suite
```

The `src/lib.rs` file contains one or more [blueprints](/contents/tech/core-concepts/blueprints-and-packages) — reusable templates that define the structure and logic of on-ledger components. Each blueprint is annotated with the `#[blueprint]` macro and contains a struct (state) and an `impl` block (functions and methods).

### Building

Compile your package to [WebAssembly](https://webassembly.org) with:

`scrypto build`
This produces a `.wasm` binary and a `.rpd` (Radix Package Definition) file in the `target/` directory. The `.rpd` contains the package's ABI — the blueprint names, functions, methods, and their type signatures — which the [Radix Engine](/contents/tech/core-protocols/radix-engine) uses to validate calls at runtime.

## Interactive Testing with resim

The [Radix Engine](/contents/tech/core-protocols/radix-engine) Simulator (`resim`) is a local ledger emulator that lets you publish packages, instantiate components, and call methods without connecting to any network. It is invaluable for rapid iteration.

### Core Commands

```
# Reset simulator state
resim reset

# Create a new account (returns address, public key, private key, owner badge)
resim new-account

# Set the active account
resim set-default-account <account_address> <private_key> <owner_badge_address>

# Publish a package (returns package address)
resim publish .

# Call a blueprint function (e.g. instantiate a component)
resim call-function <package_address> <BlueprintName> <function_name> [args...]

# Call a method on an instantiated component
resim call-method <component_address> <method_name> [args...]

# Inspect an entity's state
resim show <address>
```

### Typical Workflow

1. $1

2. $1

3. $1

4. $1

5. $1

6. $1

## Automated Testing with scrypto-test

While `resim` is great for exploration, production packages need automated tests. Radix provides two testing frameworks:

### Unit Testing: scrypto-test

The [scrypto-test](https://docs.radixdlt.com/docs/scrypto-test) framework uses an invocation-based approach — you call blueprint functions and methods directly in Rust, receiving actual [Bucket](/contents/tech/core-concepts/buckets-proofs-and-vaults) and Proof objects that you can assert against. At its core is the `TestEnvironment` struct, which encapsulates a self-contained [Radix Engine](/contents/tech/core-protocols/radix-engine) instance.

```
use scrypto_test::prelude::*;

#[test]
fn test_instantiation() -> Result<(), RuntimeError> {
    let mut env = TestEnvironment::new();
    let package = PackageFactory::compile_and_publish(
        this_package!(),
        &mut env,
        CompileProfile::Fast,
    )?;
    // Call functions, assert on the returned buckets and proofs
    Ok(())
}
```

Key utilities include `BucketFactory` and `ProofFactory` for creating test resources, with strategies like `CreationStrategy::DisableAuthAndMint` for bypassing auth in test contexts.

### Integration Testing: LedgerSimulator

The [LedgerSimulator](https://docs.rs/scrypto-test/latest/scrypto_test/ledger_simulator/struct.LedgerSimulator.html) is an in-memory ledger where you interact as an external user submitting transactions, rather than calling methods directly. It applies the same costing limits and auth checks as the real network, which makes it the right harness for end-to-end tests. Build one with `LedgerSimulatorBuilder`, publish your package, then execute manifests against it.

```
use scrypto_test::prelude::*;

#[test]
fn test_end_to_end() {
    let mut ledger = LedgerSimulatorBuilder::new().build();
    let package_address = ledger.compile_and_publish(this_package!());
    let (public_key, _private_key, account) = ledger.new_allocated_account();

    let manifest = ManifestBuilder::new()
        .lock_fee_from_faucet()
        .call_function(package_address, "Hello", "instantiate_hello", manifest_args!())
        .build();

    let receipt = ledger.execute_manifest(
        manifest,
        vec![NonFungibleGlobalId::from_public_key(&public_key)],
    );
    receipt.expect_commit_success();
}
```

Earlier releases of the framework called this type `TestRunner`. It was renamed to `LedgerSimulator`, so test code written against older tutorials will not compile against current `scrypto-test`.

Run all tests with:

`scrypto test`
This wraps `cargo test` with the correct Scrypto feature flags and environment.

## Next Steps

- [Vault and Resource Patterns](/developers/scrypto/06-vault-patterns) — the idioms for holding and moving resources inside a component

## External Links

- [Resim — Radix Engine Simulator](https://docs.radixdlt.com/docs/resim-radix-engine-simulator)

- [scrypto-test Framework — Official Docs](https://docs.radixdlt.com/docs/scrypto-test)

- [scrypto-test API Reference — docs.rs](https://docs.rs/scrypto-test/latest/scrypto_test/)

- [Testing Multi-Blueprint Packages — Official Docs](https://docs.radixdlt.com/docs/learning-to-test-a-multi-blueprint-package)