{"id":24629489,"url":"https://github.com/sharpjs/subatomix.testing","last_synced_at":"2026-02-11T03:08:06.644Z","repository":{"id":68403158,"uuid":"308950187","full_name":"sharpjs/Subatomix.Testing","owner":"sharpjs","description":"Preferred frameworks for automated testing in .NET","archived":false,"fork":false,"pushed_at":"2025-02-23T23:31:35.000Z","size":280,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T23:35:05.835Z","etag":null,"topics":["dotnet","testing"],"latest_commit_sha":null,"homepage":"","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/sharpjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2020-10-31T18:44:49.000Z","updated_at":"2025-02-23T23:31:09.000Z","dependencies_parsed_at":"2024-03-15T04:31:23.241Z","dependency_job_id":"ff9b9527-1527-4b79-bd97-4473acfe51ab","html_url":"https://github.com/sharpjs/Subatomix.Testing","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FSubatomix.Testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FSubatomix.Testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FSubatomix.Testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FSubatomix.Testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sharpjs","download_url":"https://codeload.github.com/sharpjs/Subatomix.Testing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244554042,"owners_count":20471172,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["dotnet","testing"],"created_at":"2025-01-25T06:13:05.429Z","updated_at":"2026-02-11T03:08:06.638Z","avatar_url":"https://github.com/sharpjs.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## About\n\n[![Build](https://github.com/sharpjs/Subatomix.Testing/workflows/Build/badge.svg)](https://github.com/sharpjs/Subatomix.Testing/actions)\n[![Build](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/sharpjs/Subatomix.Testing/actions)\n[![NuGet](https://img.shields.io/nuget/v/Subatomix.Testing.svg)](https://www.nuget.org/packages/Subatomix.Testing)\n[![NuGet](https://img.shields.io/nuget/dt/Subatomix.Testing.svg)](https://www.nuget.org/packages/Subatomix.Testing)\n\nMy preferred frameworks for automated testing in .NET.\n\nSee [here](https://github.com/sharpjs/Subatomix.Testing/blob/main/Subatomix.Testing/Subatomix.Testing.csproj)\nfor a list of included packages and their versions.\n\nThis package also includes the\n[`TestHarnessBase`](https://github.com/sharpjs/Subatomix.Testing/blob/main/Subatomix.Testing/TestHarnessBase.cs)\nclass, which aids my preferred technique for setup/teardown code.  Generally, I\neschew traditional `SetUp` and `TearDown` methods.  Instead, in each test, I\ncreate an instance of a disposable context class.  Construction is setup, and\ndisposal is teardown.  Because `TestContext` means something else already in\nNUnit, I call this pattern *Test Harness* instead.\n\n```csharp\n[Test]\npublic void TestSomething()\n{\n    using var h = new TestHarness();\n\n    // rest of test\n}\n\nprivate class TestHarness : TestHarnessBase\n{\n    // properties for mocks and things\n\n    public TestHarness()\n    {\n        // setup code\n    }\n\n    protected override CleanUp()\n    {\n        // teardown code\n    }\n}\n```\n\nThis pattern enables some cool things:\n\n- I can enable the C# 8\n  [nullability checker](https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references)\n  and not have to sprinkle `?` and `!` all over the test code.\n\n- Tests can run in parallel, regardless of test fixture lifetime, since there\n  is no longer any shared state within a test class.\n\n- Test-support code can be isolated away from the tests themselves.\n\nIf the\n[test fixture lifetime](https://docs.nunit.org/articles/nunit/writing-tests/attributes/fixturelifecycle.html)\nis instance-per-test-case, the test fixture itself can be a subclass of\n`TestHarnessBase`.  This results in a test fixture more closely resembling a\ntraditional one and removes the need for a `using` statement in each test,\nwhile retaining the improved nullability ergonomics.  However, directly\nsubclassing `TestHarnessBase` forfeits the isolation afforded by having a\nseparate test harness class.\n\n```csharp\n[TestFixture]\n[FixtureLifeCycle(LifeCycle.InstancePerTestCase)]\npublic class SomeTests : TestHarnessBase\n{\n    // properties for mocks and things\n\n    public TestHarness()\n    {\n        // setup code\n    }\n\n    protected override CleanUp()\n    {\n        // teardown code\n    }\n\n    [Test]\n    public void TestSomething()\n    {\n        // test\n    }\n}\n```\n\n\u003c!--\n  Copyright Subatomix Research Inc.\n  SPDX-License-Identifier: MIT\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpjs%2Fsubatomix.testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharpjs%2Fsubatomix.testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpjs%2Fsubatomix.testing/lists"}