module-zero-core-template
module-zero-core-template copied to clipboard
Issue 338 - Unit Tests Run Slow
Summary
Introduces the option of writing light-weight, fast-running unit tests in addition to the current in-memory database style integration tests. The key to this functionality is the new .AsRepository()
extension method (see below).
Details
- Moves all existing test infrastructure into an
IntegrationTests\
folder and adjusts namespaces - Adds a
\UnitTests
folder for placing fast tests into - Adds a
AbpProjectNameUnitTestBase
andAbpProjectNameUnitTestModule
into\UnitTests
that unit tests will inherit from and use - Renames
AbpProjectNameTestBase
toAbpProjectNameIntegrationTestBase
to keep the base classes clearly differentiated - Adds classes: TestQueryable, TestAsyncQueryProvider, TestAsyncEnumerable, and TestAsyncEnumerator, all of which provide the infrastructure for LINQ queries against in-memory lists of data
- Adds an
AsRepository()
extension method that creates working IRepository mocks given lists of objects (or single objects) - Adds several unit tests for UserAppService into
UnitTests\Users\UserAppService_Tests.cs
primarily for documentation purposes
To Test
- Run the tests in
UnitTests\Users\UserAppService_Tests.cs
Expected: They should all pass
Thanks a lot @lprichar 👍 We will check it for v4.2 milestone.
Fixes #338
@lprichar we have reviewed your PR and it is very good I think but we thought that this will be a bit complex for a startup template. We will keep this PR open and use it as an example for the ones who face the same performance problem on their proejcts.
Thanks again for your great contribution 😄 .