Skip to content
Fluent testing framework for remote HTTP servers.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
documentation
samples
src/MyTested.HttpServer
test/MyTested.HttpServer.Tests
.gitignore
LICENSE
MyTested.HttpServer.sln
README.md
global.json

README.md

MyTested.HttpServer  MyTested.HttpServer - Fluent testing
  for remote servers

====================================

MyTested.HttpServer is unit testing library providing easy fluent interface to test remote HTTP servers. It is testing framework agnostic, so you can combine it with the testing library of your choice (e.g. NUnit, xUnit, etc.). MyTested.HttpServer can be easily used with frameworks like AngleSharp or Json.NET in order to create HTML or JSON test assertions over a remote (or localhost) web server.

Build status license NuGet Badge

Documentation

Please see the documentation for full list of available features. Everything listed there is fully covered by unit tests.

Installation

MyTested.HttpServer is designed to work with both .NET 4.5+ and .NET Core. You can install it library using NuGet into your Test class project.

Install-Package MyTested.HttpServer

After the downloading is complete, just add using MyTested.HttpServer; and you are ready to test in the most elegant and developer friendly way.

using MyTested.HttpServer;

For other interesting packages check out:

How to use

Make sure to check out the documentation for full list of available features. You can also check out the provided samples for real-life server testing.

Basically you can create a test case by using the fluent API the library provides. You are given a static MyHttpServer class from which all assertions can be easily configured.

namespace MyApp.Tests
{
	using MyTested.HttpServer;
	
	using NUnit.Framework;

    [TestFixture]
    public class MyServerShould
    {
		private const string BaseAddress = "http://mytestedasp.net";
	
		[TestFixtureSetUp]
		public void Init()
		{
			MyHttpServer.IsLocatedAt(BaseAddress);
		}
	
        [Test]
        public void ReturnStatusCodeOk()
        {
            MyHttpServer
                .WorkingRemotely()
                .WithHttpRequestMessage(req => req.WithMethod(HttpMethod.Get))
                .ShouldReturnHttpResponseMessage()
                .WithStatusCode(HttpStatusCode.OK);
        }
	}
}

The example uses NUnit but you can use whatever testing framework you want. Basically, MyTested.HttpServer throws an unhandled exception if the assertion does not pass and the test fails.

License

Code by Ivaylo Kenov. Copyright 2015-2016 Ivaylo Kenov.

This package has MIT license. Refer to the LICENSE for detailed information.

Any questions, comments or additions?

If you have a feature request or bug report, leave an issue on the issues page or send a pull request. For general questions and comments, use the StackOverflow forum.

You can’t perform that action at this time.