# fabioCollini/DaggerMock

A JUnit rule to easily override Dagger 2 objects

Repository: https://github.com/fabioCollini/DaggerMock
Canonical: https://ross.abutalabs.com/products/daggermock
Language: Java
License: Apache-2.0
License Family: permissive
Topics: dagger, junit-rule, android, testing, mockito, espresso
Last push: 2023-02-01T09:31:05+00:00

## Health v2 (maintenance only)
Score: 32/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 0, release rhythm 35, longevity 100
- inputs: {"age_days": 3902, "days_push": 1309, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1153, forks 87 (observed 2026-08-28T04:03:47.308993+00:00)

## What it is
DaggerMock is a JUnit rule that makes it easy to override Dagger 2 provided objects with Mockito mocks in Java or Kotlin tests. It scans @Mock-annotated test fields and substitutes them into the Dagger component, avoiding the need for custom TestModules and TestComponents.

## Use cases
- override dagger 2 dependencies in junit tests
- mock objects injected by dagger in android tests
- unit test android services using mockito and dagger
- replace dagger module providers with mocks without test modules
- write espresso tests with mocked dependencies

## When to choose
- you use Dagger 2 with JUnit and want simple mock overrides
- you want to avoid boilerplate TestModule/TestComponent setup in tests
- you write Android tests in Java or Kotlin with Mockito

## When to avoid
- you use Hilt or Koin instead of Dagger 2
- you need a maintained solution - the project is in maintenance mode
- you need to mock static or null fields, which are unsupported

## Facets
- artifact type: library
- maturity: maintenance
- function: testing, mocking
- domain: testing, android-tools, developer-tools
- platform: jvm
- tags: dagger2, junit-rule, mockito, espresso, dependency-injection-testing, android

## Member repositories
- fabioCollini/DaggerMock (main) score 32

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:47.308993+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T06:33:27.696270+00:00, confidence not recorded.
  - readme: https://github.com/fabioCollini/DaggerMock (fetched 2026-08-28T04:03:47.308993+00:00, sha 89eb1719d7a1)
- Data as of 2026-08-30T08:39:29.467469+00:00.
