14

I am really frustrated with this issue. I have already tried changing the version numbers but no tests are showing in the test explorer.

In the test output window I can see this output

Starting Microsoft.Framework.TestHost [C:\Users\sul\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta4\bin\dnx.exe --appbase "path to test project" Microsoft.Framework.ApplicationHost --port 63938 Microsoft.Framework.TestHost --port 63954 list ]
Unable to start Microsoft.Framework.TestHost
========== Discover test finished: 0 found (0:00:36.5471185) ==========

This is so fragile, sometimes tests are shown then they disappear for good. Restarting VS didn't help, reinstalling the xunit/xunit runner didn't help either.

In another test project I got a different output but still not tests are showing

Starting Microsoft.Framework.TestHost [C:\Users\sul\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta4\bin\dnx.exe --appbase "path to project" Microsoft.Framework.ApplicationHost --port 63938 Microsoft.Framework.TestHost --port 64421 list ]
Connected to Microsoft.Framework.TestHost
Discovering tests in 'path to project\project.json'
========== Discover test finished: 0 found (0:00:35.9341416) ==========

This is part of my project.json

"commands": {
    "test": "xunit.runner.dnx"
  },
  "dependencies": {
    "Microsoft.AspNet.Http": "1.0.0-*",    
    "Microsoft.AspNet.Http.Core": "1.0.0-*",
    "Microsoft.AspNet.TestHost": "1.0.0-*",    
    "Moq": "4.2.1502.911",    
    "xunit": "2.0.0",
    "xunit.runners": "2.0.0"
Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
Sul Aga
  • 6,142
  • 5
  • 25
  • 37
  • I know that you have marked this as answered, but by any chance are you using ReSharper? I fixed this issue by installing the xUnit test runner extension for ReSharper and restarting Visual Studio. – dball Jul 21 '15 at 18:29
  • thank you for your comment. No I am not using Resharper – Sul Aga Jul 22 '15 at 20:55

5 Answers5

5

I've just had some issues with this when using TFS. Set it up and got it working on one machine, went onto another, Got latest code after checking in my changes, everything was showing correctly, but the test runner wasn't finding any tests at all. In the end a simple clean and rebuild on the Test project fixed it and it now finds tests.

This is my project.json

"dependencies": { "Xunit": "2.1.0-beta2-*", "Xunit.runner.dnx": "2.1.0-beta2-*" }, "commands": { "test": "xunit.runner.dnx" },

Note the capital X in the Xunit listed in dependencies. The official documentation lists is as a lower case x, but this does not work. I've emailed the repo owner to make him aware of this.

EDIT: I've spoken to the author of XUnit who assures me the lower case x does work for him and others and that it's potentially a corrupted package cache.

BenM
  • 4,218
  • 2
  • 31
  • 58
  • And if you have a corrupted package cache how do you fix it? I have also been told there's some corruption inside visual studio which can be cleared by cleaning up your %TEMP% folder – Warren P Jul 30 '15 at 19:06
1

I manage to get this to work by making sure that all the packages in all the solution projects reference the same version.

This happened to me because I was referencing the latest versions as you can see from project.json.

One other thing I did is never reference individual packages which fits the purpose only. For example in my business project I am creating a middleware and I was referencing Microsoft.AspNet.Http because I don't need the full MVC package. This caused issues in the test project so I added Microsoft.AspNet.MVC to any project that needs any sort of Http interaction i.e. httpcontext.

This may not be the ideal fix but it did work for me. I hope this helps someone else experiencing the same issue.

Sul Aga
  • 6,142
  • 5
  • 25
  • 37
1

I had some issues but got it working !

"dependencies": {
    "Test.ANNe.Compiler": "1.0.0-*",
    "xunit.runner.dnx": "2.1.0-beta2-build79"
},

"commands": {
    "Test.Console": "Test.Console",
    "test": "xunit.runner.dnx"
},

3 issues i had . 1. You can only have 1 runner ! 2. Test in command 3. Ensure the compile environment matched the environment setup in dnvm

I note your using dnx-clr-win-x86.1.0.0 which is dnx but not the dnx runner.

user1496062
  • 1,309
  • 1
  • 7
  • 22
1

The following dependencies (to be provided in project.json) worked for me (original source):

"dependencies": {
    "System.Collections": "4.0.10-beta-23019",
    "System.Linq": "4.0.0-beta-23019",
    "System.Threading": "4.0.10-beta-23019",
    "System.Runtime": "4.0.10-beta-23019",
    "Microsoft.CSharp": "4.0.0-beta-23019",

    "xunit": "2.1.0-*",
    "xunit.runner.dnx": "2.1.0-*",
    "xunit.runner.visualstudio": "2.0.1",
    "Microsoft.Framework.TestHost": "1.0.0-*",
    "Microsoft.Framework.ApplicationHost": "1.0.0-*"
}
Ashraf Alam
  • 3,500
  • 32
  • 31
1

Encountered similar issues, and changing from xunit 2.0.0-rc1 to 2.0.0-beta8 fixed the issue.

Details:

  • Project A (older version of Microsoft.AspNet.Authentication.Test) worked
  • Project B (my custom project) did not work

Setting Project B to use:

"xunit.runner.aspnet": "2.0.0-aspnet-beta8*"

Instead of:

"xunit.runner.aspnet": "2.0.0-aspnet-*"

Fixed the issue. Project B was picking up:

xunit.runner.aspnet (2.0.0-aspnet-rc1-15669)

Project A used the following project.json:

{
    "compilationOptions": {
        "warningsAsErrors": "true"
    },
    "dependencies": {
        "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*",
        "Microsoft.AspNet.Authentication.Facebook": "1.0.0-*",
        "Microsoft.AspNet.Authentication.Google": "1.0.0-*",
        "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-*",
        "Microsoft.AspNet.Authentication.OAuthBearer": "1.0.0-*",
        "Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*",
        "Microsoft.AspNet.Authentication.Twitter": "1.0.0-*",
        "Microsoft.AspNet.DataProtection": "1.0.0-*",
        "Microsoft.AspNet.TestHost": "1.0.0-*",
        "Moq": "4.2.1312.1622",
        "xunit.runner.aspnet": "2.0.0-aspnet-*"
    },
    "commands": {
        "test": "xunit.runner.aspnet"
    },
    "frameworks": {
        "dnx451": {
            "dependencies": {
                "Shouldly": "1.1.1.1"
            }
        }
    }
}

Project B used:

{
    "dependencies": {
        "Microsoft.AspNet.Authentication": "1.0.0-*",
        "Microsoft.AspNet.Authentication.OAuth": "1.0.0-*",
        "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*",
        "Microsoft.Framework.DependencyInjection": "1.0.0-*",
        "Microsoft.AspNet.TestHost": "1.0.0-*",
        "Moq": "4.2.1312.1622",
        "xunit.runner.aspnet": "2.0.0-aspnet-*"
    },
    "commands": {
        "test": "xunit.runner.aspnet"
    },
    "frameworks": {
        "dnx451": {
            "dependencies": {
                "Shouldly": "1.1.1.1"
            }
        }
    }
}
Eric Patrick
  • 2,097
  • 2
  • 20
  • 31