MvcIntegrationTestFramework 1.0.8

.NET Framework 4.5
NuGet\Install-Package MvcIntegrationTestFramework -Version 1.0.8
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
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
#r "nuget: MvcIntegrationTestFramework, 1.0.8"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MvcIntegrationTestFramework as a Cake Addin
#addin nuget:?package=MvcIntegrationTestFramework&version=1.0.8

// Install MvcIntegrationTestFramework as a Cake Tool
#tool nuget:?package=MvcIntegrationTestFramework&version=1.0.8

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

Product Versions
.NET Framework net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.8 12,379 5/30/2018
1.0.7 6,991 7/13/2017
1.0.6 1,149 4/6/2017
1.0.5 700 4/6/2017
1.0.4 732 4/5/2017
1.0.3 705 4/5/2017
1.0.2 1,119 4/5/2017
1.0.1 896 4/4/2017
1.0.0 739 4/3/2017

Adding dll resolve-by-name flag to AppHost