module-zero-core-template icon indicating copy to clipboard operation
module-zero-core-template copied to clipboard

Issue 338 - Unit Tests Run Slow

Open lprichar opened this issue 6 years ago • 2 comments

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 and AbpProjectNameUnitTestModule into \UnitTests that unit tests will inherit from and use
  • Renames AbpProjectNameTestBase to AbpProjectNameIntegrationTestBase 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

  1. Run the tests in UnitTests\Users\UserAppService_Tests.cs

Expected: They should all pass

lprichar avatar Oct 13 '18 16:10 lprichar

Thanks a lot @lprichar 👍 We will check it for v4.2 milestone.

Fixes #338

ismcagdas avatar Oct 15 '18 06:10 ismcagdas

@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 😄 .

ismcagdas avatar Dec 18 '18 07:12 ismcagdas