Skip to content
pubscout

hive_test

1.0.1, released 6 years ago by an unverified publisher

Initialize a temporary Hive database for unit tests

Repository archived
$ flutter pub add hive_test
Source repository

What it does

Provides a real Hive instance that can be used in tests. It creates a temporary directory, opens boxes, and cleans up after each test run.

AI-written summary of version 1.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Writing unit or integration tests that involve Hive boxes
  • Testing read/write transactions in a Flutter app
  • Running tests that need a clean Hive state each time

Skip it when

  • Using in production code
  • Replacing a persistent Hive database for app data

Strengths

  • Simple API – just call setUpTestHive() and tearDownTestHive()
  • No code generation or build_runner required
  • Works with the real Hive implementation, so tests reflect production behavior

Weaknesses

  • Only intended for tests – not suitable for runtime use
  • Requires the hive package as a dependency
  • Limited to the platforms supported by Hive

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
2

Add hive_test to dev_dependencies and import it in your test files. No special permissions or build steps are needed.

setUp(() async {
  await setUpTestHive();
});

tearDown(() async {
  await tearDownTestHive();
});

Works with

Packages commonly used together with hive_test: ones it builds on, ones built on it, and its own family.