Mini Test Framework for .NET
ℹ️ Coming soon to a package manager near you... probably...
This is really just a fun project I'm hacking on to relearn a ton of
C#
MiniSpec
is:
Read the documentation below for syntax, usage, instructions, etc.
What if .NET tests were much simpler? No [Test]
attributes. No Assert
.
string greeting = "Hello";
bool TestShouldPass() => greeting == "Hello";
bool TestShouldFail() => greeting == "Hey there";
MiniSpec.Tests.Run(args);
This is the entire code for a valid MiniSpec project ⤴
What if one test framework provided both xUnit and BDD style tests?
using MiniSpec;
class DogTests {
void TestBark() { /* ... */ }
}
Spec.Describe("Dog", dog => {
dog.Can("Bark", () => { /* ... */ })
});
Also makes clever use of C# 9 Top-level Statements and C# 7 Local Functions
What if one framework was really tiny and focused on just the testing syntax?
No Assert
provided.
Use Assert
from xUnit
or NUnit
. Or FluentAssertions
. Or NExpect
. It all works.
using NUnit.Framework;
void TestTheAnswer() {
Assert.That(TheAnswer, Is.EqualTo(42));
}
MiniSpec
has a very small interface, see syntax overview below!
What if really simple Dependency Injection was included?
TODO
What if conventional terms like SetUp
and TearDown
just worked?
class TestDog {
void Setup() { /* runs before each test */ }
void Teardown() { /* runs after each test */ }
void ItCanBark() { /* test code */ }
void ItCanSit() { /* test code */ }
}
What if you could configure a test framework with your own preferred syntax?
class Specification {
void Prepare() { /* setup code */ }
void Cleanup() { /* teardown code */ }
void ExampleOne() { /* test code */ }
void ExampleTwo() { /* test code */ }
}
$ dotnet test --before Prepare --after Cleanup --test Example
What if the test output was pretty, colorful, short, and easy to read?
(screenshot)
Also supports TAP out-of-the-box. Just run
dotnet run --tap
For JUnit XML:
dotnet add package MiniSpec.JUnit
anddotnet run --junit
What if a test framework worked on all versions of .NET, going back to .NET 2.0?
Packages available for:
- .NET 5
- .NET Core 1.0 - 3.1
- .NET Standard 1.0 - 2.1
- .NET Framework 2.0 - 4.8
What if you could easily configure your own output?
You can easily write your own output reporter.
You don't even need a MiniSpec
dependency!
Also supports:
- Custom test discovery
- Custom executor for tests
- Custom executor for the whole suite
What if all the documentation you needed was simply in the README?
The entire syntax is documented here in this README!
You can also head over to https://minispec.io to see it on a pretty website.
Written with developer fun and friendliness in mind. Have fun with it!
I recently returned to C#
from many years away and wasn't enjoying the existing dotnet test
developer experience.
I wanted to scrape the rust off of my C#
skills by making something and... apparently this is what I ended up with!
Coming soon! Still authoring. Having fun with it 😄