Testing

Complete guide for running tests in NCN Network v2.


Quick Start

# Run all tests
cargo test --all

# Run tests with output
cargo test --all -- --nocapture

# Run specific package tests
cargo test -p gateway_node

Test Categories

Unit Tests

Located alongside source code in src/ directories:

# Run all unit tests
cargo test --lib --all

# Run specific module tests
cargo test -p gateway_node payment::tests

Integration Tests

Located in tests/ directories:

Contract Tests

Located in contracts/test/:


Running Tests

All Tests

By Package

By Test Name

Ignored Tests


Test Configuration

Environment Variables

Test Filters


Smart Contract Tests

Foundry Tests

Specific Contract Tests

Test Coverage


Integration Testing

End-to-End Tests

Test with Docker


Test Writing Guidelines

Unit Test Example

Integration Test Example

Contract Test Example


Test Utilities

Test Helpers

Mock Services


CI/CD Testing

GitHub Actions Example


Test Coverage

Generate Coverage Report

Coverage Targets

Component
Target Coverage

Common Types

90%

Gateway Node

80%

Compute Node

75%

P2P Registry

80%

Smart Contracts

95%


Debugging Failed Tests

Enable Backtrace

Run Single Test Verbose

Run with Logging

Debug in IDE

Configure VS Code launch.json:


Next Steps

Last updated