Skip to content
Skills Library
Programming · Testing

abp-testing

/abp-testing

ABP Framework v10.x (10.4–10.6) testing quick reference: integration tests, *TestBase, SQLite in-memory, Shouldly, NSubstitute, data seeding, CurrentUser/CurrentTenant.Change. Use when you need to write tests in ABP.

Repository
abp-skills ↗
Licence
MIT
Last repository change
14.08.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 14.08.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

ABP Framework v10.x (10.4–10.6) testing quick reference: integration tests, *TestBase, SQLite in-memory, Shouldly, NSubstitute, data seeding, CurrentUser/CurrentTenant.Change. Use when you need to write tests in ABP.

Original author description

ABP Framework v10.x (10.4–10.6) testing quick reference: integration tests, *TestBase, SQLite in-memory, Shouldly, NSubstitute, data seeding, CurrentUser/CurrentTenant.Change. Use when you need to write tests in ABP.

How it works

  1. Trigger
  2. Base Classes
  3. Test (AAA + Shouldly)
  4. Data Seed
  5. Disable Authorization / Mock
  6. User / Tenant
  7. Best Practices
  8. Related
Original SKILL.md headings · 79 lines, 239 words
SKILL.md preview
---
name: abp-testing
description: "ABP Framework v10.x (10.4–10.6) testing quick reference: integration tests, *TestBase, SQLite in-memory, Shouldly, NSubstitute, data seeding, CurrentUser/CurrentTenant.Change. Use when you need to write tests in ABP."
---

# ABP Framework — Testing

ABP v10.x testing. **Integration tests** are preferred: real services + SQLite in-memory DB, internal services not mocked.

## Trigger

"ABP test", "integration test", "TestBase", "test data seed", "Shouldly", "NSubstitute".

## Base Classes

| Project | Base Class |
|---|---|
| `*.Domain.Tests` | `*DomainTestBase` |
| `*.Application.Tests` | `*ApplicationTestBase` |
| `*.EntityFrameworkCore.Tests` | `*EntityFrameworkCoreTestBase` |

## Test (AAA + Shouldly)

```csharp
public class BookAppService_Tests : MyProjectApplicationTestBase
{
    private readonly IBookAppService _svc;
    public BookAppService_Tests() => _svc = GetRequiredService<IBookAppService>();

    [Fact]
    public async Task Should_Create_Book()
    {
        var result = await _svc.CreateAsync(new CreateBookDto { Name = "New", Price = 19.99m });
        result.Id.ShouldNotBe(Guid.Empty);
        result.Name.ShouldBe("New");
    }

    [Fact]
    public async Task Should_Throw_When_Invalid()
        => await Should.ThrowAsync<AbpValidationException>(async () =>
               await _svc.CreateAsync(new CreateBookDto { Name = "" }));
}
```

Naming: `Should_ExpectedBehavior_When_Condition`. Exception: `ex.Code.ShouldBe("MyProject:ErrorCode")`.

## Data Seed

```csharp
public class TestDataSeedContributor : IDataSeedContributor, ITransientDependency
{
    public async Task SeedAsync(DataSeedContext context)
        => await _bookRepository.InsertAsync(new Book(TestBookId, "Test", 19.99m), autoSave: true);
}
```

## Disable Authorization / Mock

```csharp
context.Services.AddAlwaysAllowAuthorization();           // disable permissions

var emailSender = Substitute.For<IEmailSender>();          // NSubstitute (external only)
context.Services.AddSingleton(emailSender);
```

## User / Tenant

```csharp
using (CurrentUser.Change(TestData.UserId)) { /* ... */ }
using (CurrentTenant.Change(TestData.TenantId)) { /* ... */ }
```

## Best Practices

1. Integration tests + SQLite in-memory, don't mock internal services
2. Keep each test independent, use meaningful seed data
3. Cover edge cases + verify exception `Code`

## Related

- [DDD](../abp-ddd/SKILL.md) · [Authorization](../abp-authorization/SKILL.md) · [Multi-Tenancy](../abp-multitenancy/SKILL.md) · [Development Flow](../abp-development-flow/SKILL.md)
- ABP Docs: https://abp.io/docs/latest/testing

Versions

RepositoryScoreLicence
This page · burakdmir/abp-skills100MIT
burakdmir/abp-skills100MIT

Database snapshot: 13.11.2026 · package version 0a56869cc818 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100abp-framework
    ABP Framework v10.x (10.4–10.6) core quick reference: solution templates, layered architecture, module system, base classes, Clock/GuidGenerator/CurrentUser/LazyServiceProvider, .NET 10. Use when creating an ABP project, or when architecture or core conventions are needed.
  • 100test-abp-applications
    Write or fix integration tests for an ABP application against the generated *TestBase — resolving services, controlling the unit of work, seeding data, faking the current user/tenant, exercising the real `[Authorize]` pipeline, and proving transaction rollback across EF Core and…
  • 100testing-guide
    Write tests for an FSH feature — xUnit + Shouldly + NSubstitute + AutoFixture, with naming and AAA conventions. Use when adding unit/handler/validator/entity tests. Full rules in .agents/rules/testing.md + integration-testing.md.
  • 100abp-framework
    ABP Framework v10.x (10.4–10.6) core guide: solution templates (app, app-nolayers, microservice), layered architecture, module system, base classes (ApplicationService/DomainService), Clock/GuidGenerator/CurrentUser/LazyServiceProvider, .NET 10. Use when creating an ABP project,…
  • 100abp-cli-commands
    Command-line workflow for the ABP Framework abp CLI — creating/scaffolding solutions, updating packages, installing client libs, generating proxies, adding packages/modules, bundling Blazor WASM, logging into abp.io, and switching to local ABP source. USE FOR: running `abp new`,…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.