Skip to content

Markop Test is a free, open-source, focused testing tool for the ASP.NET Framework.

License

Notifications You must be signed in to change notification settings

MarkopDev/MarkopTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Markop Test

NuGet Nuget MIT License GitHub stars

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.

Getting Started

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]
2- Inside the newly created project add a reference to the project you want to test

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 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!!

Usage

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!!

A sample implementation looks like this:

unit-test-app-factory


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

email-normalize


Integration Test

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.

integration-test

Usage

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

integration-test-eg

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.

Functional Test

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.

Usage

  • TODO

Load Test

Usage

  • Todo

Present Methods

1- Initializer(IServiceProvider hostServices):

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!!

2- ConfigureTestServices(IServiceCollection services)

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!!

A sample implementation looks like this:

unit-test-app-factory


3- GetUrl(string url, string controllerName, string testMethodName)

GetUrl helps you to build the correct address to which HttpClient is going to send the request.

4- ValidateResponse(HttpResponseMessage httpResponseMessage,TFetchOptions fetchOptions)

ValidateResponse enables you to customise the response validation proccess according to expected behaviour of your API.

Contributions

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.

LICENSE

MIT

About

Markop Test is a free, open-source, focused testing tool for the ASP.NET Framework.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •