{"id":22873699,"url":"https://github.com/nullean/xunit-partitions","last_synced_at":"2026-06-17T12:31:39.741Z","repository":{"id":221667353,"uuid":"754822148","full_name":"nullean/xunit-partitions","owner":"nullean","description":"An XUnit Test Framework implementation allowing long lived fixtures without giving up concurrency.","archived":false,"fork":false,"pushed_at":"2026-02-17T14:53:23.000Z","size":66,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-25T01:54:22.984Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nullean.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-08T20:36:38.000Z","updated_at":"2026-02-17T14:52:42.000Z","dependencies_parsed_at":"2024-12-13T14:31:37.004Z","dependency_job_id":"56dbea82-c2c3-4280-8d1d-73f99103243f","html_url":"https://github.com/nullean/xunit-partitions","commit_stats":null,"previous_names":["nullean/xunit-partitions"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/nullean/xunit-partitions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullean%2Fxunit-partitions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullean%2Fxunit-partitions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullean%2Fxunit-partitions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullean%2Fxunit-partitions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nullean","download_url":"https://codeload.github.com/nullean/xunit-partitions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nullean%2Fxunit-partitions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34225349,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T14:29:55.197Z","updated_at":"2026-06-17T12:31:39.723Z","avatar_url":"https://github.com/nullean.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nullean.Xunit.Partitions\n\n\u003ca href=\"https://www.nuget.org/packages/Nullean.Xunit.Partitions/\"\u003e\u003cimg src=\"https://img.shields.io/nuget/v/Nullean.Xunit.Partitions?color=blue\u0026style=plastic\" /\u003e\u003c/a\u003e\n\n\u003cimg src=\"https://github.com/nullean/xunit-partitions/raw/main/nuget-icon.png\" align=\"right\"\ntitle=\"Logo \" width=\"220\" height=\"220\"\u003e\n\nAn `XunitTestFramework` implementation that introduces the concept of \"partitions\".\n\nA `IPartitionFixture{TLifetime}` allows tests to inject a long lived object to share.\n\nOnly a single partition will run at a time in contrast with xUnit's `ICollectionFixture{TFixture}`\nHowever unlike `ICollectionFixture{TFixture}` this library's `IPartitionFixture{TLifetime}`\ndoes not mark a concurrency barrier, tests belonging to a single **partition still run concurrently**\n\nIn fact each `IPartitionFixture{TLifetime}` can declare its own desired concurrency through\n`IPartitionLifetime.MaxConcurrency`\n\nIf you want to share a few (say 0-20) long running objects over 1000's of tests this library will work for you. \nIf you instead have many test collections each with only a few tests xUnit native collections will suit better.\n\nBecause each partititon only calls `InitializeAsync` and `DisposeAsync` just before and after its test will run this makes it more appropiate then assembly fixtures which might bootstrap too early and dispose too late.\n\n## Setup\n\nProvide the following Assembly level attribute anywhere in your test project.\n\n```csharp\nusing Nullean.Xunit.Partitions;\nusing Xunit;\n[assembly: TestFramework(Partition.TestFramework, Partition.Assembly)]\n```\n\nThis will ensure xUnit bootstraps the partition test framework shipped with this library.\n\n\n## Providing options\n\nOptions to control the parition test framework can be provided similarly through the `PartitonOptions` Assembly level\nattribute.\n\nHere you can control filters to only run certain partitions and/or tests.\n\n#### Setup.cs\n```csharp\nusing Nullean.Xunit.Partitions;\nusing My.Tests;\nusing Xunit;\n\n[assembly: TestFramework(Partition.TestFramework, Partition.Assembly)]\n//optional only needed if you want to specify execution options to PartitionTestFramework\n[assembly: PartitionOptions(typeof(MyPartitioningOptions))]\n\nnamespace My.Tests;\n\n/// \u003csummary\u003e Allows us to control the xunit partitioning test pipeline \u003c/summary\u003e\npublic class MyPartitioningOptions : PartitionOptions\n{\n\tpublic MyPartitioningOptions()\n\t{\n\t\tPartitionFilterRegex = \"LongLivedObject\";\n\t\tTestFilterRegex = null;\n\t}\n}\n\n```\n\n## Usage\n\n```csharp\nnamespace Nullean.Xunit.Partitions.Tests;\n\n\npublic class NoStateClass\n{\n\t[Fact]\n\tpublic void SimpleTest() =\u003e 1.Should().Be(1);\n}\n\npublic class LongLivedObject : IPartitionLifetime\n{\n\tprivate static long _initialized;\n\tprivate static long _disposed;\n\n\tpublic long Initialized =\u003e _initialized;\n\tpublic long Disposed =\u003e _disposed;\n\n\tpublic Task InitializeAsync()\n\t{\n\t\tInterlocked.Increment(ref _initialized);\n\t\treturn Task.CompletedTask;\n\t}\n\n\tpublic Task DisposeAsync()\n\t{\n\t\tInterlocked.Increment(ref _disposed);\n\t\treturn Task.CompletedTask;\n\t}\n\n\tpublic int? MaxConcurrency =\u003e null;\n}\n\npublic class SharedState1Class(LongLivedObject longLivedObject) : IPartitionFixture\u003cLongLivedObject\u003e\n{\n\t[Fact]\n\tpublic void StaticInitializedShouldNotIncrease() =\u003e longLivedObject.Initialized.Should().Be(1);\n\n\t[Fact]\n\tpublic void DisposeShouldNotHaveHappened() =\u003e longLivedObject.Disposed.Should().Be(0);\n}\n\npublic class SharedState2Class(LongLivedObject longLivedObject) : IPartitionFixture\u003cLongLivedObject\u003e\n{\n\t[Fact]\n\tpublic void StaticInitializedShouldNotIncrease() =\u003e longLivedObject.Initialized.Should().Be(1);\n\n\t[Fact]\n\tpublic void DisposeShouldNotHaveHappened() =\u003e longLivedObject.Disposed.Should().Be(0);\n}\n\n```\n\n`SharedState1Class` and `SharedState2Class` both depend on `LongLivedObject` and so will receive a single shared \ninstance AFTER `InitializeAsync` has run. The tests of each **will** run concurrently. \n\n`DisposeAsync` will run before the next partition's state will `InitializeAsync`\n\n\n`NoStateClass` does not belong to any partition. All tests with no partitions are treated as part of an empty partition. \nThese tests will all run concurrently too.\n\nHowever no partition will ever run concurrently with another **by design**. \n\nThis allows partition's state to run expensive operations (e.g starting docker containers, processes, bootstrap playwright states),\nin isolation.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullean%2Fxunit-partitions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnullean%2Fxunit-partitions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullean%2Fxunit-partitions/lists"}