Reo.Core.Xunit.IntegrationTesting
6.0.31579
See the version list below for details.
dotnet add package Reo.Core.Xunit.IntegrationTesting --version 6.0.31579
NuGet\Install-Package Reo.Core.Xunit.IntegrationTesting -Version 6.0.31579
<PackageReference Include="Reo.Core.Xunit.IntegrationTesting" Version="6.0.31579" />
paket add Reo.Core.Xunit.IntegrationTesting --version 6.0.31579
#r "nuget: Reo.Core.Xunit.IntegrationTesting, 6.0.31579"
// Install Reo.Core.Xunit.IntegrationTesting as a Cake Addin
#addin nuget:?package=Reo.Core.Xunit.IntegrationTesting&version=6.0.31579
// Install Reo.Core.Xunit.IntegrationTesting as a Cake Tool
#tool nuget:?package=Reo.Core.Xunit.IntegrationTesting&version=6.0.31579
Xunit.IntegrationTesting
Расширение фреймворка xUnit для выполнения интеграционного тестирования
Использование
Первоначальная настройка
В проекте с тестами необходимо определить файл со следующим содержимым:
using Reo.Core.IntegrationTesting.TestFramework.Mongo;
using Reo.Core.IntegrationTesting.TestFramework.Postgres;
using Reo.Core.Xunit.IntegrationTesting.Attributes;
[assembly:EnableIntegrationTestingFramework]
[assembly:RaiseContainer<PostgresTestContainer<TestingContext>>]
[assembly:RaiseContainer<MongoTestContainer>]
Атрибут EnableIntegrationTestingFramework
должен быть указан в обязательном порядке. Он указывает xUnit
, что необходимо использовать расширенный тестовый фреймворк вместо обычного.
Атрибут RaiseContainer
нужен для того, чтобы при запуске тестов запустился контейнер указанного типа. В прошлом контейнеры запускались при старте каждого тестового класса, теперь запускается единственный контейнер для всех тестов примерно сразу после загрузки сборки.
На данный момент реализованы четыре контейнера (их можно найти в пакете Reo.Core.IntegrationTesting
):
- Postgres (PostgresTestContainer{TDbContext} и PostgresFixture{TDbContext})
- Mongo (MongoTestContainer и MongoFixture)
- Redis (RedisTestContainer и RedisFixture)
- Elastic (ElasticTestContainer и ElasticFixture)
Написание тестов
В тестовом классе необходимо указать какую фикстуру вы хотите использовать.
CollectionFixture
Фикстура создается один раз на запускаемую пачку тестов
// CollectionDefinition.cs
[CollectionDefinition(nameof(PostgresDefinition))]
public sealed class PostgresDefinition : ICollectionFixture<PostgresFixture<TestingDbContext>>
{ }
// TestClass.cs
[Collection(nameof(PostgresDefinition))]
public sealed class TestClass
{
private readonly PostgresFixture<TestingDbContext> _fixture;
public TestClass(PostgresFixture<TestingDbContext> fixture)
{
_fixture = fixture;
}
[Fact]
public void Verify()
{
// ...
}
}
К сожалению, CollectionDefinition
необходимо описывать в каждой сборке, иначе xUnit
их не увидит (см. документацию xUnit)
ClassFixture
Фикстура создается один раз на запускаемый тестовый класс
public sealed class TestClass : IClassFixture<MongoFixture>
{
private readonly MongoFixture _fixture;
public TestClass(MongoFixture fixture)
{
_fixture = fixture;
}
[Fact]
public void Verify()
{
// ...
}
}
И то, и другое
xUnit
не запрещает внедрять IClassFixture
и ICollectionFixture
одновременно:
[Collection(nameof(PostgresDefinition))]
public sealed class TestClass : IClassFixture<MongoFixture>
{
// ...
public TestClass(PostgresFixture<TestingDbContext> postgresFixture, MongoFixture mongoFixture)
{
// ...
}
// ...
}
Регистрация артефактов из фикстуры в AutoMocker
При внедрении фикстуры используйте готовые методы расширения:
public sealed class TestClass :
IClassFixture<PostgresFixture<TestingDbContext>>,
IClassFixture<MongoFixture>,
IClassFixture<ElasticFixture>,
IClassFixture<RedisFixture>
{
private readonly AutoMocker _mocker = new();
// ...
public TestClass(
PostgresFixture<TestingDbContext> postgresFixture,
MongoFixture mongoFixture,
ElasticFixture elasticFixture,
RedisFixture redisFixture)
{
// ...
_mocker
.SetupPostgres(postgresFixture)
.SetupMongo(mongoFixture)
.SetupElastic(elasticFixture)
.SetupRedis(redisFixture);
}
// ...
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 7.0.0)
- xunit.extensibility.execution (>= 2.7.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Reo.Core.Xunit.IntegrationTesting:
Package | Downloads |
---|---|
Reo.Core.IntegrationTesting
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
6.0.31779 | 66 | 5/22/2024 |
6.0.31778 | 74 | 5/22/2024 |
6.0.31777 | 67 | 5/22/2024 |
6.0.31776 | 66 | 5/22/2024 |
6.0.31775 | 68 | 5/22/2024 |
6.0.31774 | 69 | 5/21/2024 |
6.0.31773 | 76 | 5/21/2024 |
6.0.31772 | 87 | 5/20/2024 |
6.0.31771 | 85 | 5/16/2024 |
6.0.31770 | 74 | 5/15/2024 |
6.0.31769 | 86 | 5/15/2024 |
6.0.31768 | 89 | 5/15/2024 |
6.0.31767 | 74 | 5/15/2024 |
6.0.31766 | 90 | 5/15/2024 |
6.0.31764 | 81 | 5/14/2024 |
6.0.31763 | 76 | 5/14/2024 |
6.0.31762 | 75 | 5/14/2024 |
6.0.31761 | 82 | 5/14/2024 |
6.0.31760 | 85 | 5/14/2024 |
6.0.31759 | 88 | 5/13/2024 |
6.0.31758 | 86 | 5/13/2024 |
6.0.31757 | 72 | 5/13/2024 |
6.0.31756 | 78 | 5/12/2024 |
6.0.31755 | 80 | 5/12/2024 |
6.0.31754 | 86 | 5/12/2024 |
6.0.31753 | 90 | 5/8/2024 |
6.0.31751 | 95 | 5/7/2024 |
6.0.31749 | 94 | 5/6/2024 |
6.0.31748 | 98 | 5/6/2024 |
6.0.31747 | 102 | 5/6/2024 |
6.0.31746 | 64 | 5/3/2024 |
6.0.31745 | 51 | 5/3/2024 |
6.0.31744 | 53 | 5/3/2024 |
6.0.31743 | 51 | 5/2/2024 |
6.0.31742 | 96 | 4/27/2024 |
6.0.31741 | 94 | 4/27/2024 |
6.0.31740 | 96 | 4/26/2024 |
6.0.31739 | 89 | 4/26/2024 |
6.0.31738 | 100 | 4/26/2024 |
6.0.31737 | 104 | 4/26/2024 |
6.0.31735 | 101 | 4/25/2024 |
6.0.31734 | 89 | 4/25/2024 |
6.0.31733 | 88 | 4/25/2024 |
6.0.31732 | 91 | 4/25/2024 |
6.0.31731 | 79 | 4/25/2024 |
6.0.31730 | 97 | 4/24/2024 |
6.0.31729 | 88 | 4/24/2024 |
6.0.31728 | 93 | 4/24/2024 |
6.0.31727 | 89 | 4/23/2024 |
6.0.31726 | 75 | 4/23/2024 |
6.0.31725 | 90 | 4/23/2024 |
6.0.31724 | 92 | 4/22/2024 |
6.0.31723 | 92 | 4/22/2024 |
6.0.31722 | 99 | 4/22/2024 |
6.0.31721 | 97 | 4/22/2024 |
6.0.31720 | 90 | 4/22/2024 |
6.0.31719 | 88 | 4/22/2024 |
6.0.31718 | 90 | 4/22/2024 |
6.0.31717 | 92 | 4/22/2024 |
6.0.31716 | 88 | 4/22/2024 |
6.0.31715 | 103 | 4/20/2024 |
6.0.31714 | 102 | 4/19/2024 |
6.0.31713 | 80 | 4/19/2024 |
6.0.31712 | 78 | 4/19/2024 |
6.0.31711 | 94 | 4/19/2024 |
6.0.31710 | 80 | 4/19/2024 |
6.0.31709 | 88 | 4/19/2024 |
6.0.31708 | 89 | 4/18/2024 |
6.0.31707 | 84 | 4/18/2024 |
6.0.31706 | 82 | 4/18/2024 |
6.0.31705 | 81 | 4/17/2024 |
6.0.31704 | 102 | 4/17/2024 |
6.0.31703 | 90 | 4/17/2024 |
6.0.31702 | 91 | 4/17/2024 |
6.0.31701 | 87 | 4/16/2024 |
6.0.31700 | 85 | 4/16/2024 |
6.0.31699 | 87 | 4/16/2024 |
6.0.31698 | 80 | 4/16/2024 |
6.0.31697 | 80 | 4/16/2024 |
6.0.31696 | 79 | 4/16/2024 |
6.0.31695 | 75 | 4/16/2024 |
6.0.31694 | 81 | 4/16/2024 |
6.0.31693 | 81 | 4/16/2024 |
6.0.31692 | 78 | 4/15/2024 |
6.0.31691 | 79 | 4/15/2024 |
6.0.31690 | 90 | 4/15/2024 |
6.0.31688 | 97 | 4/12/2024 |
6.0.31687 | 73 | 4/12/2024 |
6.0.31686 | 79 | 4/12/2024 |
6.0.31685 | 78 | 4/12/2024 |
6.0.31684 | 78 | 4/11/2024 |
6.0.31683 | 88 | 4/10/2024 |
6.0.31682 | 81 | 4/10/2024 |
6.0.31681 | 80 | 4/10/2024 |
6.0.31680 | 85 | 4/10/2024 |
6.0.31679 | 76 | 4/10/2024 |
6.0.31678 | 77 | 4/10/2024 |
6.0.31677 | 89 | 4/9/2024 |
6.0.31676 | 93 | 4/9/2024 |
6.0.31675 | 90 | 4/8/2024 |
6.0.31674 | 97 | 4/8/2024 |
6.0.31673 | 99 | 4/8/2024 |
6.0.31672 | 77 | 4/8/2024 |
6.0.31671 | 77 | 4/8/2024 |
6.0.31670 | 87 | 4/8/2024 |
6.0.31669 | 85 | 4/8/2024 |
6.0.31668 | 93 | 4/5/2024 |
6.0.31667 | 94 | 4/5/2024 |
6.0.31666 | 100 | 4/3/2024 |
6.0.31665 | 93 | 4/3/2024 |
6.0.31663 | 97 | 4/3/2024 |
6.0.31662 | 89 | 4/3/2024 |
6.0.31661 | 91 | 4/2/2024 |
6.0.31660 | 94 | 4/1/2024 |
6.0.31659 | 85 | 4/1/2024 |
6.0.31658 | 82 | 4/1/2024 |
6.0.31657 | 88 | 3/29/2024 |
6.0.31656 | 82 | 3/29/2024 |
6.0.31655 | 85 | 3/29/2024 |
6.0.31654 | 93 | 3/29/2024 |
6.0.31653 | 78 | 3/29/2024 |
6.0.31651 | 73 | 3/29/2024 |
6.0.31650 | 78 | 3/29/2024 |
6.0.31649 | 79 | 3/29/2024 |
6.0.31648 | 79 | 3/29/2024 |
6.0.31647 | 77 | 3/29/2024 |
6.0.31646 | 99 | 3/29/2024 |
6.0.31645 | 82 | 3/28/2024 |
6.0.31644 | 84 | 3/28/2024 |
6.0.31643 | 90 | 3/28/2024 |
6.0.31642 | 85 | 3/28/2024 |
6.0.31639 | 89 | 3/28/2024 |
6.0.31638 | 74 | 3/28/2024 |
6.0.31637 | 98 | 3/27/2024 |
6.0.31636 | 120 | 3/27/2024 |
6.0.31631 | 88 | 3/27/2024 |
6.0.31626 | 95 | 3/26/2024 |
6.0.31625 | 100 | 3/25/2024 |
6.0.31618 | 100 | 3/20/2024 |
6.0.31617 | 91 | 3/20/2024 |
6.0.31616 | 103 | 3/20/2024 |
6.0.31615 | 91 | 3/20/2024 |
6.0.31614 | 111 | 3/19/2024 |
6.0.31613 | 106 | 3/18/2024 |
6.0.31612 | 116 | 3/18/2024 |
6.0.31611 | 117 | 3/18/2024 |
6.0.31610 | 110 | 3/18/2024 |
6.0.31609 | 103 | 3/15/2024 |
6.0.31608 | 103 | 3/14/2024 |
6.0.31607 | 115 | 3/13/2024 |
6.0.31606 | 103 | 3/13/2024 |
6.0.31605 | 101 | 3/13/2024 |
6.0.31604 | 99 | 3/12/2024 |
6.0.31603 | 98 | 3/12/2024 |
6.0.31602 | 127 | 3/7/2024 |
6.0.31601 | 105 | 3/7/2024 |
6.0.31600 | 114 | 3/7/2024 |
6.0.31599 | 109 | 3/6/2024 |
6.0.31598 | 100 | 3/6/2024 |
6.0.31597 | 105 | 3/6/2024 |
6.0.31596 | 103 | 3/6/2024 |
6.0.31595 | 114 | 3/6/2024 |
6.0.31594 | 103 | 3/4/2024 |
6.0.31593 | 91 | 3/4/2024 |
6.0.31590 | 99 | 3/1/2024 |
6.0.31589 | 94 | 3/1/2024 |
6.0.31588 | 98 | 3/1/2024 |
6.0.31587 | 88 | 3/1/2024 |
6.0.31586 | 96 | 3/1/2024 |
6.0.31585 | 86 | 3/1/2024 |
6.0.31584 | 98 | 3/1/2024 |
6.0.31583 | 89 | 3/1/2024 |
6.0.31582 | 100 | 2/29/2024 |
6.0.31581 | 92 | 2/29/2024 |
6.0.31580 | 98 | 2/29/2024 |
6.0.31579 | 102 | 2/29/2024 |
6.0.31578 | 99 | 2/29/2024 |
6.0.31577 | 94 | 2/29/2024 |
6.0.31576 | 97 | 2/29/2024 |
6.0.31575 | 99 | 2/28/2024 |