abp-testing

Writes integration tests for ABP application services, domain services, and repositories.

Updated Jul 21, 2026
One-click install
npx skills add https://github.com/afonsoft/gamehub --skill abp-testing-afonsoft
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: abp-testing
Source: https://github.com/afonsoft/gamehub/tree/main/.claude/skills/abp-testing
Command: npx skills add https://github.com/afonsoft/gamehub --skill abp-testing-afonsoft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests for ABP-based .NET applications requires knowing framework-specific patterns like GetRequiredService, IDataSeedContributor, and WithUnitOfWorkAsync, and developers often struggle to structure tests correctly across Domain, Application, and EntityFrameworkCore test projects. ## Core Features & Use Cases - Integration Test Patterns: Provides templates for application service and domain service tests using real services with SQLite in-memory databases instead of mocks. - Assertion and Seeding Guidance: Covers Shouldly assertions, test data seeding via IDataSeedContributor, and naming conventions following the Should_ExpectedBehavior_When_Condition pattern. - Use Case: When adding a new BookAppService to an ABP modular monolith, use this Skill to generate a complete test class with seeded data, authorization bypass via AddAlwaysAllowAuthorization, and multi-tenancy test cases. ## Quick Start Write an ABP integration test for my application service that creates an entity and validates duplicate-name business exceptions.

Frequently Asked Questions about abp-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write integration tests for ABP application services?▼

Inherit from your project's ApplicationTestBase, resolve the service with GetRequiredService, and call its methods directly against a real SQLite in-memory database. Assert results with Shouldly, such as result.Name.ShouldBe or Should.ThrowAsync for exceptions.

Should I use unit tests or integration tests in ABP projects?▼

ABP recommends integration tests over unit tests. Tests run with real services and a fresh in-memory database per test, so internal services are not mocked and behavior is verified end to end.

How do I seed test data in ABP tests?▼

Implement IDataSeedContributor with ITransientDependency and insert entities through repositories in the SeedAsync method. Use static Guid constants for test entity IDs so tests can reference seeded records deterministically.

How do I disable authorization in ABP tests?▼

Call context.Services.AddAlwaysAllowAuthorization() inside the ConfigureServices override of your test module. This bypasses permission checks so application service tests can run without configuring test users and roles.

Can I mock external services like email senders in ABP tests?▼

Yes, use NSubstitute in ConfigureServices to create substitutes such as Substitute.For<IEmailSender>() and register them with AddSingleton. Only external services should be mocked; internal services use real implementations.

How do I test multi-tenancy filtering in ABP?▼

Wrap the test logic in CurrentTenant.Change(tenantId) to switch the ambient tenant context, then assert that repository or app service queries return only records belonging to that tenant.