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

Notification

Icon
Error

Xunit and Skip breaking the runner
enkafan
#1 Posted : Tuesday, May 19, 2015 4:59:37 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/19/2015(UTC)
Posts: 2
Location: United States of America

Was thanked: 1 time(s) in 1 post(s)
I have some unit tests I need to skip so I was going to use a custom FactAttribute. This is causing the unit test discovery to throw an exception. I'm pretty sure this is an Xunit problem not an Ncrunch bug, but between the VS test runner, R# and teamcity I'm only seeing problems in NCrunch so I suspect it's a combo of an exception being thrown by xUnit that NCrunch could handle better. NCrunch failed to find ANY tests at all in a project with this attribute and crashed hard with the bug in the discoverer for that one test.

Edit : when I wrote this I thought the xUnit prerelease version of the runner was working, but I lied. I think I just got a false positive as I was switching out nuget packages

Exception is

Code:
An error occurred while analysing this project after it was built: System.Exception: Error while discovering test 'XunitSkip.UnitTests.Skip_test':System.InvalidOperationException: Sequence contains more than one element
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at Xunit.Sdk.XunitTestCase.Initialize()
   at Xunit.Sdk.TestMethodTestCase.EnsureInitialized()
   at Xunit.Sdk.TestMethodTestCase.get_SkipReason()
   at nCrunch.Module.XUnit2.Integration.XUnitDiscoveryMessageSink.discoverTest(ITestCase testCase, Object[] arguments)
   at nCrunch.Module.XUnit2.Integration.XUnit2TestFramework.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName)
   at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, TestFrameworkDescription[] frameworks, ComponentUniqueName testComponentUniqueName)
   at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(TestFrameworkDescription[] applicableFrameworks, ComponentUniqueName testComponentUniqueName)


App to reproduce is pretty simple. New console app, add xunit 2.0 and the Visual Studio Runner

Code:
using Xunit;

namespace XunitSkip
{
    public class UnitTests
    {
        [Fact]
        public void Whatever()
        {
            Assert.True(true);
        }

        [Fact]
        [Skip("skipping it")]
        public void Skip_test()
        {
            Assert.True(true);
        }        
    }

    public sealed class SkipAttribute : FactAttribute
    {
        public SkipAttribute(string reason = "just cause")
        {
            Skip = reason;
        }
    }
}
enkafan
#2 Posted : Tuesday, May 19, 2015 5:48:10 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/19/2015(UTC)
Posts: 2
Location: United States of America

Was thanked: 1 time(s) in 1 post(s)
ok, my problem with xunit was human error on my part. I'm obviously throwing two facts on there which was blowing it up. Still would have been nice if this would have been marked as a failed test rather than preventing the whole assembly from failing
1 user thanked enkafan for this useful post.
Remco on 5/19/2015(UTC)
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.024 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download