Skip to content

docs: add actor unit testing guide - #1861

Closed
wynx1123 wants to merge 1 commit into
dapr:masterfrom
wynx1123:docs/actor-unit-testing
Closed

docs: add actor unit testing guide#1861
wynx1123 wants to merge 1 commit into
dapr:masterfrom
wynx1123:docs/actor-unit-testing

Conversation

@wynx1123

Copy link
Copy Markdown

Summary

Adds a comprehensive Actor Unit Testing Guide to help developers test Dapr Actors effectively, as requested in #1531.

Contents

The guide covers these practical patterns:

Section Description
Actor Lifecycle Key inherited members and testable API surface
Isolation Testing Creating actors with ActorHost for fast unit tests
Mocking StateManager Constructor injection + Moq patterns
Mocking ActorProxyFactory Testing cross-actor calls without Dapr runtime
Timers & Reminders Testing registrations
Full Test Suite Complete BankActor test class example
Integration Testing Dapr sidecar test patterns

Design

  • All code samples are ready to copy-paste
  • Uses Moq as the mocking framework (Dapr's test projects already use it)
  • Covers the three main testing scenarios:
    1. Unit tests — fast, no Dapr runtime
    2. Mock-based tests — mock StateManager / ProxyFactory
    3. Integration tests — with Dapr sidecar

Related

Closes #1531

@wynx1123
wynx1123 requested review from a team as code owners June 30, 2026 07:42
@WhitWaldo

Copy link
Copy Markdown
Contributor

@wynx1123 Thank you for putting this together. Could you please sign your commits so we can accept this?

@WhitWaldo

Copy link
Copy Markdown
Contributor

@wynx1123 Having looked through this, I think it might be a better option to put into the Dapr .NET SDK documentation repository rather than in this one so there's better visibility. There isn't much documentation persisted in this repository outside of the examples.

If you can ping me when you have something in place over in dapr/docs, I'd be happy to review it there!

@wynx1123

Copy link
Copy Markdown
Author

Thanks for the guidance, @WhitWaldo!

I'll sign the commit here and move the documentation over to dapr/docs as you suggested. I'll ping you there once the PR is up!

Add docs/actor-unit-testing.md covering:
- Actor lifecycle overview and testable API surface
- Unit testing actors in isolation with ActorHost
- Mocking StateManager with constructor injection and Moq
- Mocking IActorProxyFactory for cross-actor call tests
- Timer and reminder registration testing
- Full BankActor test suite example
- Integration testing with Dapr sidecar
- Key principles: dependency injection, test isolation, fast hosts

Closes dapr#1531

Signed-off-by: wynx1123 <wynx1123@users.noreply.github.com>
@wynx1123

Copy link
Copy Markdown
Author

DCO signed and documentation moved to dapr/docs — PR is at dapr/docs#5230 @WhitWaldo

@wynx1123 wynx1123 closed this Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build out examples/documentation documenting actor unit testing

2 participants