MvcIntegrationTestFramework 1.0.8

Integration test harness for ASP.Net MVC 5. Allows you to fully integration test an MVC web project without needing to host under IIS or similar. Allows access to both server state and client responses in a single assertion.

Install-Package MvcIntegrationTestFramework -Version 1.0.8
dotnet add package MvcIntegrationTestFramework --version 1.0.8
<PackageReference Include="MvcIntegrationTestFramework" Version="1.0.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MvcIntegrationTestFramework --version 1.0.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

MvcIntegrationTestFramework

Integration test harness for ASP.Net MVC 5. Allows you to fully integration test an MVC web project without needing to host under IIS or similar. Allows access to both server state and client responses in a single assertion.

Batteries included
https://www.nuget.org/packages/MvcIntegrationTestFramework

This fork targets MVC 5, VS2015.

Everything should just work out of the box, no need for post build steps.

Usage

In your test set-up start a new AppHost targeting the folder containing your MVC application:

	this.appHost = AppHost.Simulate("MyMvcApplication");

Then for each test flow, start a browsing session, make your calls and assert against the results:

	this.appHost.Start(browsingSession =>
	{
		// Request the root URL
		RequestResult result = browsingSession.Get("/welcome");

		// Check the result status
		Assert.That(result.IsSuccess);

		// Make assertions about the ActionResult
		var viewResult = (ViewResult)result.ActionExecutedContext.Result;
		Assert.AreEqual("Index", viewResult.ViewName);
		Assert.AreEqual("Welcome to ASP.NET MVC!", viewResult.ViewData["Message"]);

		// Or make assertions about the rendered HTML
		Assert.IsTrue(result.ResponseText.Contains("<!DOCTYPE html"));
	});

See the MyMvcApplication.Tests project and the HomeControllerTests.cs file for more examples.

The framework injects it's own System.Web.Optimization bundle provider, which supplies blank CSS and Javascript files.

Known issues

Simple Injector

Simple Injector's [assembly: WebActivator.PostApplicationStartMethod(...)] injection can cause problems with the ASP.Net hosting enviroment.
You can remove the assembly level injector and call your setup from Global.aspx to solve this.

TFS Builds

TFS Build servers can restructure your project, causing the test framework to not find the MVC project directory.
To work around this, you can pass multiple potential locations for your project to the Simulate function, and the first one to be found will be used.

For example,

    appHost = AppHost.Simulate(
        "Source\\Web\\MyMvcApplication",             // Local solution location
        "a\\_PublishedWebsites\\MyMvcApplication");  // TFS build system, under ...\Agent\_work\1\a\_PublishedWebsites ...

Icon via game-icones.net

MvcIntegrationTestFramework

Integration test harness for ASP.Net MVC 5. Allows you to fully integration test an MVC web project without needing to host under IIS or similar. Allows access to both server state and client responses in a single assertion.

Batteries included
https://www.nuget.org/packages/MvcIntegrationTestFramework

This fork targets MVC 5, VS2015.

Everything should just work out of the box, no need for post build steps.

Usage

In your test set-up start a new AppHost targeting the folder containing your MVC application:

	this.appHost = AppHost.Simulate("MyMvcApplication");

Then for each test flow, start a browsing session, make your calls and assert against the results:

	this.appHost.Start(browsingSession =>
	{
		// Request the root URL
		RequestResult result = browsingSession.Get("/welcome");

		// Check the result status
		Assert.That(result.IsSuccess);

		// Make assertions about the ActionResult
		var viewResult = (ViewResult)result.ActionExecutedContext.Result;
		Assert.AreEqual("Index", viewResult.ViewName);
		Assert.AreEqual("Welcome to ASP.NET MVC!", viewResult.ViewData["Message"]);

		// Or make assertions about the rendered HTML
		Assert.IsTrue(result.ResponseText.Contains("<!DOCTYPE html"));
	});

See the MyMvcApplication.Tests project and the HomeControllerTests.cs file for more examples.

The framework injects it's own System.Web.Optimization bundle provider, which supplies blank CSS and Javascript files.

Known issues

Simple Injector

Simple Injector's [assembly: WebActivator.PostApplicationStartMethod(...)] injection can cause problems with the ASP.Net hosting enviroment.
You can remove the assembly level injector and call your setup from Global.aspx to solve this.

TFS Builds

TFS Build servers can restructure your project, causing the test framework to not find the MVC project directory.
To work around this, you can pass multiple potential locations for your project to the Simulate function, and the first one to be found will be used.

For example,

    appHost = AppHost.Simulate(
        "Source\\Web\\MyMvcApplication",             // Local solution location
        "a\\_PublishedWebsites\\MyMvcApplication");  // TFS build system, under ...\Agent\_work\1\a\_PublishedWebsites ...

Icon via game-icones.net

Release Notes

Adding dll resolve-by-name flag to AppHost

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.8 3,024 5/30/2018
1.0.7 3,142 7/13/2017
1.0.6 431 4/6/2017
1.0.5 256 4/6/2017
1.0.4 274 4/5/2017
1.0.3 272 4/5/2017
1.0.2 329 4/5/2017
1.0.1 342 4/4/2017
1.0.0 281 4/3/2017