Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

NCrunch fails on tests that resharper passes using xUnit
Paddy1990
#1 Posted : Wednesday, May 28, 2014 11:57:18 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/28/2014(UTC)
Posts: 2
Location: United Kingdom

I have a project using xUnit with lots of unit tests that were all passing when using Resharper to run the tests. Now I've just downloaded NCrunch (which I really like by the way) and it fails a lot of the tests. An example is shown below:

Code:
[Fact]
public void GetMarket_ShowMarketPickerPage()
{
     var numberOfFlagsExpected = MockCollections.MockFlagCollection.Count;

     var response = Browser.Get("/");
     response.Body["div[class='flags slider__panel']"].ShouldExist();
     response.Body["li[class^='flags__']"].ShouldExistExactly(numberOfFlagsExpected);
}


For this particular method the error is: Nancy.Testing.AssertException: Nancy.Testing.AssertException : The selector did not match any elements in the document.

Another example using [Theory]:

Code:
[Theory]
[InlineData("terms", "terms-popup")]
[InlineData("privacy", "privacy-popup")]
[InlineData("parentscorner", "parentscorner-popup")]
[InlineData("cookies", "cookies-popup")]
[InlineData("contact", "contact-popup")]
[InlineData("playsafe", "playsafe-popup")]
public void GetContent_GetPageForMarketAndLanguage(string contentName, string expectedArticleId)
{
     LanguageService.GetLanguagesForMarket("ar")
                     .Returns(MockCollections.MockLanguageCollection.Where(x => x.Market == "ar"));

     var contentRoute = string.Format("/ar/en/{0}", contentName);
     var response = Browser.Get(contentRoute);

     // Check the 
     var expectedArticleTag = string.Format(@"article[id=""{0}""]", expectedArticleId);
     response.Body[expectedArticleTag].ShouldExistOnce();
}


And the error for this method is: Nancy.Testing.AssertException: Nancy.Testing.AssertException : The collection contained no values.

why am I getting these errors on NCrunch but not other test runners? Any explaination on this would be greatly appreciated, thanks
Remco
#2 Posted : Wednesday, May 28, 2014 12:24:15 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for posting!

It can be difficult to completely understand everything that is happening in these tests with only the test code available, but I would speculate that these tests are making assumptions about the structure of the solution they are working in - perhaps they are referencing a web project using a relative path from the test directory?

For NCrunch to perform its concurrent testing, it introduces some new constraints on how some integration tests should be written. I recommend reading up on the Project Atomicity page, as I think this may contain useful information for your situation. It's also worth skimming through some of the other documentation pages around 'Considerations and Constraints' to help arm yourself with more knowledge about how the NCrunch engine works and what you need to be aware of when you write your tests.
Paddy1990
#3 Posted : Wednesday, May 28, 2014 3:10:02 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/28/2014(UTC)
Posts: 2
Location: United Kingdom

Thanks for the reply, I'll have a look into it.

I've just been looking into the tests that fail and it seems that all of them have `Nancy.Testing.Browser` class in them shown here `var response = Browser.Get(contentRoute);`. Now some tests pass when using this class so it's probably not that code thats failing the tests but it seems to be a common occurrence.
Remco
#4 Posted : Wednesday, May 28, 2014 10:25:32 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
I do remember there being some issues with Nancy's testing framework not handling NCrunch straight out of the box. My memory isn't very clear in this area, but I think it was doing something like trying to resolve the web project's location dynamically (which would often fail under NCrunch, as the solution is structured differently in the NCrunch workspaces).

There's some interesting Q/A on stackoverflow that you might want to look at. I remember this being a common problem but one that was not terribly difficult to solve.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.031 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download