Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zaid-ajaj/tinytest
Tiny single file test "framework" for small projects
https://github.com/zaid-ajaj/tinytest
csharp tdd testing
Last synced: about 1 month ago
JSON representation
Tiny single file test "framework" for small projects
- Host: GitHub
- URL: https://github.com/zaid-ajaj/tinytest
- Owner: Zaid-Ajaj
- Created: 2017-10-04T12:53:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-22T11:26:46.000Z (almost 7 years ago)
- Last Synced: 2024-11-12T14:53:50.416Z (3 months ago)
- Topics: csharp, tdd, testing
- Language: C#
- Size: 17.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TinyTest
Tiny single file test "framework" for small projects because you don't always need full fledged testing frameworks.## Usage
- Create a console project (the test runner)
- Copy the file [TinyTest.cs](https://github.com/Zaid-Ajaj/TinyTest/blob/master/TinyTest.cs) to the project
- Start writing tests
```csharp
using TinyTest;class Program
{
static int Add(int x, int y) => x + y;static int Main(string[] args)
{
Test.Module("Simple Tests");Test.Case("Add(x, y) works", () =>
{
var result = Enumerable.Range(1, 100).Aggregate(Add);
Test.Equal(result, 5050);
});Test.CaseAsync("Async tests too!", async () =>
{
await Task.Delay(200);
Test.Equal(1, 1);
});return Test.Report();
}
}
```
Test Results:![ScreenShot](screenshot.png)
## Grouping tests
You can group tests using modules:
```csharp
Test.Module("Math tests");
Test.Case("Case 1", () => ... );
Test.Case("Case 2", () => ... );Test.Module("Database tests");
Test.Case("Case 1", () => ... );
Test.Case("Case 2", () => ... );Test.Report();
```
## Test reportersYou can implement your own test reporters easily. The call `Test.Report()` only calls `Test.ReportUsing(new ConsoleReporter())` where `ConsoleReporter` is an `ITestReporter`. i.e.:
```csharp
public interface ITestReporter
{
void Report(IEnumerable modules);
}public class ConsoleReporter : ITestReporter
{
/* ... */
}
```