Markop Test is a free, open-source, focused testing tool for .Net. Using Markop Tests you can easily write Unit tests, Integration tests, Functional tests and Load tests.
In order to use Markop test you should do the following steps:
1- Create a class library project inside your solution and name it according to the kind of test you want to perform, e.g., "FunctionalTest". Don't forget to add the project to your solution.
dotnet new classlib -n [YOUR PROJECT NAME]
dotnet sln add [YOUR PROJECT NAME]
3- Install the Markop Test package inside your test project:
Nuget:
Install-Package MarkopTest
Or using dotnet CLI:
dotnet add package MarkopTest
4- Depending on the kind of testing you want to perform you should go to: Unit test , Integration test, Functional test or Load test.
Unit Tests are supposed to test the behaviour of a smallest piece of code. Markop Test is here to make this process fully automated. Writing Unit Tests has never been easier before!!
First of all you should create an AppFactory
class extend it from UnitTestFactory
class.
Then you need to override Initializer
and ConfigureTestServices
methods
Initializer
method gives you the ability to initiate a custom database for testing all you have to do is to build your custom initializer and called it here. Markop Test will take care of the rest!!
ConfigureTestServices
method gives you the ability to register/remove the services. This way you will have full control over the registered services of your app before you start testing!!
Then you need to create a class and extend it from your own AppFactory
class
Next, you should define a method inside your class and put your pereferable test attribute. It can be [Fact]
or [Theory]
or any other valid test attribute in Xunit.
Now you can start writing your test code inside your method!!
For example in the below code we wrote code to test an extention method called EmailNormalize
A part of software testing that tests individual code components to validate interactions among different software
system modules.
We use these tests are used to test the app's infrastructure and the whole framework, often including the following
components:
- Database
- File system
- Request-response pipeline
Markop provides an app factory abstraction to make it easy to implement a clean integration test and view output instead of using external API testing tools such as Postman.
First of all you should create an AppFactory
class extend it from IntegrationTestFactory
class.
Next you need to override Initializer, ConfigureTestServices, GetUrl, ValidateResponse methods.
Then you need to create a class and extend it from your own AppFactory
class. For a cleaner implementation we suggest creating a class for each controller in your API.
Use Endpoint
atrribute to specify a pattern for request addresses.
Next, you should define a method inside your class and put your pereferable test attribute. It can be [Fact]
or [Theory]
or any other valid test attribute in Xunit.
Now you can start writing your test code inside your method!!
For example in the below code we wrote code to test a SignIn
API
Attention1: At runtime variables like controller
and action
inside Endpoint
atrribute will be intitalized with name of your class and name of your method.
Attention2: Markop Test automatically ignors the ["Test", "Tests", "Controller"] at end of your class name.
For example in the above code the controller
value will be "Account" and the action
value will be "SignIn". The requests will be sent to /Account/SignIn
endpoint.
The test determines the product's functionality that can be done by aggregating integration tests and comparing the
actual output with the predetermined output.
We use case scenarios for functional testing. For example, in a news system, we must test managing news scenarios such
as Create, Edit and Delete news entity, you can implement transaction workflow in your system.
As in the integration testing, Markop provides an app factory abstraction to make it easy to implement a clean
functional test.
- TODO
- Todo
Initializer
method gives you the ability to initiate a custom database for testing. All you have to do is to build your custom initializer and called it here. Markop Test will take care of the rest!!
ConfigureTestServices
method gives you the ability to register/remove the services. This way you will have full control over the registered services of your app before you start testing!!
GetUrl
helps you to build the correct address to which HttpClient is going to send the request.
ValidateResponse
enables you to customise the response validation proccess according to expected behaviour of your API.
If you're interested in contributing to this project, first of all, We would like to extend my heartfelt gratitude.
Please feel free to reach out to us if you need help.
MIT