MvcIntegrationTestFramework 1.0.8

dotnet add package MvcIntegrationTestFramework --version 1.0.8
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.
<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 and Polyglot Notebooks. 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 Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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 15,238 5/30/2018
1.0.7 8,402 7/13/2017
1.0.6 1,517 4/6/2017
1.0.5 897 4/6/2017
1.0.4 947 4/5/2017
1.0.3 915 4/5/2017
1.0.2 1,506 4/5/2017
1.0.1 1,139 4/4/2017
1.0.0 956 4/3/2017

Adding dll resolve-by-name flag to AppHost