https://github.com/sakapon/klibrary.testing
A library for unit testing using MSTest.
https://github.com/sakapon/klibrary.testing
mstest testing unit-testing
Last synced: 3 months ago
JSON representation
A library for unit testing using MSTest.
- Host: GitHub
- URL: https://github.com/sakapon/klibrary.testing
- Owner: sakapon
- License: mit
- Created: 2020-04-17T01:21:24.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-27T13:03:03.000Z (about 5 years ago)
- Last Synced: 2025-01-17T09:45:09.845Z (4 months ago)
- Topics: mstest, testing, unit-testing
- Language: C#
- Homepage:
- Size: 83 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KLibrary.Testing
[](LICENSE)
[](https://www.nuget.org/packages/KLibrary.Testing/)
[](https://www.nuget.org/packages/KLibrary.Testing/)A library for unit testing using MSTest.
## Setup
KLibrary.Testing is published to [NuGet Gallery](https://www.nuget.org/packages/KLibrary.Testing/). Install the library to test projects by NuGet.## Features
- Extends the Assert class
- AreNearlyEqual, etc.
- Creates a test method to be simplified
- Wrapping AreEqual or AreNearlyEqual
- Creates random data
- Measures execution time## Usage
Firstly, add `using` directive for `KLibrary.Testing` namespace.
```c#
using System;
using KLibrary.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
```### AreNearlyEqual Method
Asserts the specified values are nearly equal, with specifying the upper bound of the absolute error `10^d`.
```c#
Assert2.AreNearlyEqual(3.14, Math.PI, -2);
Assert2.AreNearlyEqual(Math.E, Math.Pow(1.0000001, 10000000), -6);
```### Test Method Wrapping
Creates a function from the function to be tested.
```c#
// Before:
Assert.AreEqual(81, Math.Pow(3, 4));
Assert.AreEqual(64, Math.Pow(4, 3));// After:
var test = TestHelper.CreateAreEqual(Math.Pow);
test(3, 4, 81);
test(4, 3, 64);
```## Target Frameworks
- .NET Standard 2.0
- .NET Framework 4.5### Dependencies
- [MSTest.TestFramework](https://www.nuget.org/packages/MSTest.TestFramework/) (≥ 1.3.2)## Release Notes
- **v4.0.6** The first release.