xUnit tests not being discovered

R4n D3v's Avatar

R4n D3v

01 Mar, 2015 09:10 AM

Hi,

AppVeyor is an awesome service. Thanks for making it available!

I am having a minor problem. If you can let me know how to enable verbose logging, I can troubleshoot myself as well.
I setup a CI for a simple project: https://ci.appveyor.com/project/r4nd0md3v3l0p3r/fizzbuzz/build/1.0.3#L11

It builds fine but AppVeyor is unable to discover the xUnit tests. I have xUnit 1.9.2 (the last stable release before 2.0 RC).
The tests are working fine from inside VS.

Can you please help me understand why my tests aren't being discovered.

Thanks,
R4n D3v

  1. Support Staff 1 Posted by Feodor Fitsner on 02 Mar, 2015 01:38 AM

    Feodor Fitsner's Avatar

    Yeah, that's weird. I see FizzBuzz.UnitTests.fsproj references xunit.dll which is required for assembly to be discovered. Will take a look more closely.

  2. 2 Posted by James Skimming on 02 Mar, 2015 10:33 AM

    James Skimming's Avatar

    I've had this exact same issue, which incidental was previously in ReSharper (or more precisely the xunit extension), and is still in NCrunch.

    Just because your reference an assembly in the project references, doesn't mean the compiled assembly will ultimately reference the assembly. If you do not directly use any components in a referenced assembly the compiler does not add it to the assembly manifest.

    If you run ildasm.exe (from a developer command prompt) and open up the test assembly, you will find it does not reference xunit in its manifest, but does reference xunit.extensions.

    You only have one test:

    module FizzBuzz.UnitTests
    
    open Xunit
    open FsUnit.Xunit
    open Xunit.Extensions
    
    [<Theory>]
    [<InlineData(1, "1")>]
    [<InlineData(2, "2")>]
    [<InlineData(3, "Fizz")>]
    [<InlineData(5, "Buzz")>]
    [<InlineData(6, "Fizz")>]
    [<InlineData(10, "Buzz")>]
    [<InlineData(15, "FizzBuzz")>]
    [<InlineData(225, "FizzBuzz")>]
    let GivenInputNumberReturnsExpectedLabel inputNumber expectedLabel =
        FizzBuzz inputNumber |> should equal expectedLabel
    

    While I'm not familiar with F#, I know that TheoryAttribute and InlineDataAttribute are in xunit.extensions.

    To work around this I often add an empty test to reference the FactAttribute, it's C#, but I'm sure you can translate :).

    [Fact]
    pubic void JustWork()
    {
    }
    

    Attentively add an Assert.True(true) to a test which will also result in a direct reference to xunit. I find as the test assembly grows, I eventually add a legitimate reference to xunit, then I remove the workaround.

  3. Support Staff 3 Posted by Feodor Fitsner on 02 Mar, 2015 05:33 PM

    Feodor Fitsner's Avatar

    Yeah, this is probably the case. Thanks, James, for elaborating on that!

  4. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:54 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac