Routing tests that pass locally, fail on build server

19 views
Skip to first unread message

Tomas Lycken

unread,
Jul 19, 2011, 8:21:02 AM7/19/11
to mvccontrib-discuss
I have a problem very similar to this one[1], but since that is quite
old (sept '09) and basically only says "upgrade your build runners",
I'm not sure my problem has the same cause.

[1]:
http://groups.google.com/group/mvccontrib-discuss/browse_frm/thread/d682a65f81b9334e/39230b03864d8422?lnk=gst&q=route+tests+on+build+server#39230b03864d8422

I have a bunch of tests that make use of the .ShouldMapTo<T>()
extension (see code below) that all pass on my machine, but fail on
the build server. We have the NUnit console runner checked into the
version control system, so it shouldn't be a versioning problem,
unless the TeamCity task to run NUnit grabs a console runner from
somewhere else on its own. (But all the other tests work, so it
definitely has a consolerunner *somewhere*...)

I don't know how to troubleshoot this further, so any help is greatly
appreciated.

I'm running NUnit-2.5.10, and the msbuild script has the following (in
suitable places):

<PropertyGroup>
<NUnitPath Condition="'$(NUnitPath)' == ''">$(RootPath)/packages/
NUnit.2.5.10.11092/Tools</NUnitPath>
</PropertyGroup>
<NUnitTeamCity
Assemblies="@(TestAssemblies)"
NUnitVersion="NUnit-2.5.10"
Condition=" '$(teamcity_dotnet_nunitlauncher_msbuild_task)' !=
'' " />

This is a sample test that passes on my machine, but fails on the
build server:

[TestFixture]
public class SampleTests
{
[SetUp]
public void Init()
{
// MvcApplication is my application type, defined in
Global.asax.cs
MvcApplication.RegisterRoutes(RouteTable.Routes);
}
[TearDown]
public void Exit()
{
RouteTable.Routes.Clear();
}

[Test]
public void AddObjectIsRouted()
{
"~/Inspection/
AddObject/".Should().MapTo<InspectionController>(c =>
c.AddObject(null, null));
}
}

Jeremy Skinner

unread,
Jul 19, 2011, 8:38:59 AM7/19/11
to mvccontri...@googlegroups.com
Because the route testing extensions make use of the global RouteTable.Routes property, it's possible that other tests in your project are modifying this collection prior to the routing tests being run, which could cause them to fail.

The first thing I'd suggest is making sure you clear the route collection *before* you register the routes (I see you're already doing this in the TearDown, but try it in the SetUp before registration too):

  [SetUp]
   public void Init()
   {
       RouteTable.Routes.Clear();
       MvcApplication.RegisterRoutes(RouteTable.Routes);
   }

Jeremy


--
Contact Jeffrey Palermo or Eric Hexter with specific questions about the MvcContrib project.  Or go to http://mvccontrib.org

To unsubscribe from this group, send email to mvccontrib-disc...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/mvccontrib-discuss?hl=en

Reply all
Reply to author
Forward
0 new messages