Skip to content

SelenoHost.Run() throws under MsTest (when using Deployment settings) #55

Closed

Description

@joshka

Running up a test spike of Seleno, there was no guidance about requiring NUnit, so I created a blank MVC project with an MsTest unit test assembly beside it and added the following test:

SelenoHost.Run("SelenoSpike.WebApp", 11111);
var page1 = SelenoHost.NavigateToInitialPage<Page1>("Home/Index");
Assert.AreEqual("Index", page1.Title);

which threw:

Test method SelenoSpike.WebApp.Tests.SelenoTests.CanTestSeleno threw exception: System.NullReferenceException: Object reference not set to an instance of an object.
    at TestStack.Seleno.Configuration.WebServers.ProjectLocation.GetSolutionFolderPath() in c:\ConsoleBuildAgent\work\f035b8dd08e41a61\src\TestStack.Seleno\Configuration\WebServers\ProjectLocation.cs: line 42   at TestStack.Seleno.Configuration.WebServers.ProjectLocation.FromFolder(String webProjectFolderName) in c:\ConsoleBuildAgent\work\f035b8dd08e41a61\src\TestStack.Seleno\Configuration\WebServers\ProjectLocation.cs: line 33   at TestStack.Seleno.Configuration.SelenoHost.Run(String webProjectFolder, Int32 portNumber, Action`1 configure) in c:\ConsoleBuildAgent\work\f035b8dd08e41a61\src\TestStack.Seleno\Configuration\SelenoHost.cs: line 50   at SelenoSpike.WebApp.Tests.SelenoTests.CanTestSeleno() in SelenoTests.cs: line 13

Analysis suggests that there's Environment.CurrentDirectory magic going on to figure out the path to the solution. I'm not quite sure how MsTest deployment works well enough to rip this out / fix for MsTest (switching to NUnit is not necessarily a bad option either), however it's worth keeping in mind that Seleno doesn't at present work out of the box with MsTest in the default configuration.

Activity

  1. mwhelan commented on Jun 26, 2013

    @mwhelan
    Member

    Hi, @joshka , yes that looks like a bug. NUnit tests run in the bin directory of the test project (Environment.CurrentDirectory) so the code works up to the folder that contains your .sln file and then down until it finds the web app folder. I'm not an mstest user but it seems it runs in a temp folder separate from the project so this assumption doesn't work!

    Will try to sort that soon as we should support mstest. Thanks for making us aware of it. If you are OK with using NUnit in the meantime then you should be good.

    Also, I take your point about there not being enough documentation. We are working on that, but in the meantime I have a couple of blog posts that might help:
    http://michael-whelan.net/seleno-04
    http://michael-whelan.net/getting-started-with-seleno

    Hope that helps!
    Michael

  2. joshka commented on Jul 1, 2013

    @joshka
    Author

    A little further info, we had a .testsettings file for use with TFS Lab Management deploys. I switched to a local .runsettings file (the new 2012 approach) and can now run MsTest tests locally without issue.
    I'll still need to run this under deployment conditions on the lab environment, but I can probably configuration drive a test at url using .WithWebServer()

  3. ghost assigned on Aug 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions