0

I've been trying to find something on this but can't see what the problem is. If I use the code below, with nothing added all my tests disappear. If I remove the AutoData attribute, they all come back. I've seen somewhere that it may have something to do with the dependency of AutoFixture on xunit.extensions (AutoFixture in F#) but the answer wasn't clear enough for me to be able to solve my problem. I'm using xunit in a C# MVC5 project.

I ran Add-BindingRedirect (as mentioned in that link) and in fact xunit.extensions were not in the app.config at all so I added it in, but it made no difference... so I'm not sure where to go from there. Any advice?

[Theory, AutoData]
public void AutoFixtureAutoData(int number1, int number2)
{
}
Community
  • 1
  • 1
Aiden
  • 1
  • 1
  • Which version of xUnit.net is installed? – Mark Seemann Feb 10 '15 at 22:17
  • xUnit Version 1.9.2.1705 and xUnit.extensions also version 1.9.2.1705. Ploeh.AutoFixture is 3.23.1.0 and Ploeh.AutoFixture.Xunit is also 3.23.1.0 – Aiden Feb 11 '15 at 08:22
  • It sounds strange that "xunit.extensions were not in the app.config", but it's a bit vague, so I'm not sure what's going on. What do you mean by "all my tests disappear"? – Mark Seemann Feb 11 '15 at 08:42
  • All xUnit tests in the VS Test Explorer disappear. Resharper Unit Test Explorer seems to still see them, but tries to run them and is unable to – Aiden Feb 11 '15 at 09:05
  • It *may* be a test runner issue... At the moment, that's my best guess. Sometimes we see that some test runners behave incorrectly in various corner cases. What happens if you use one of the [native xUnit.net test runners](http://www.nuget.org/packages/xunit.runners/1.9.2) - either the console runner, or the GUI runner? – Mark Seemann Feb 11 '15 at 10:06
  • I have this already installed. Does the Visual Studio test explorer not use this runner automatically, or what do I have to do to use it explicitly? – Aiden Feb 11 '15 at 11:29
  • I don't know how the Visual Studio test explorer works (I never use it), but perhaps [the xUnit.net documentation may prove helpful](http://xunit.github.io/docs/running-tests-in-vs.html). – Mark Seemann Feb 11 '15 at 11:33
  • No can't see anything there. So there's nothing I can do then? There is no detailed information on how these things should be set up? – Aiden Feb 11 '15 at 13:11
  • I got it to work by removing all packages and installing 'AutoFixture with xUnit.net Data Theories' first since it has a dependency on an earlier version of xUnit (well... it says anything newer than that version that didn't seem to work too well for me). So, after all that I have xunit 1.8.0.1549 installed but and the tests do not disappear when using AutoFixture and AutoData but then since it is an older version then other functions are not available (or can I have two versions installed at the same time... that seems like a bad idea) – Aiden Feb 11 '15 at 15:34
  • You should be able to use newer versions, such as xUnit.net 1.9.2, but you'll have to invoke Add-BindingRedirect. That's what I do, and I never have any problems with it. I'd be happy to help, but I'll need more detailed steps to reproduce the issue. – Mark Seemann Feb 11 '15 at 15:39
  • maybe I'm doing it incorrectly then as when I use Add-BindingRedirect it seems to be ignored. I thought it could be a problem with versions when I installed Moq and that threw an error about not finding the required file even though I set the bindingredirects for it also. Is there something I'm missing then about the bindingredirects? – Aiden Feb 11 '15 at 15:46
  • Below is what I had in my app.config. But I guess I should have changed the oldVersion to 1.8.0.1549 then, is that right? – Aiden Feb 11 '15 at 15:49
  • That looks fine... I still think you may have an issue with the test runner. Can you reproduce the issue in one of the native xUnit.net test runners. – Mark Seemann Feb 11 '15 at 16:00
  • I've installed and uninstalled so many times now that I don't know what is installed anymore... it seems to be a bit messed up. I don't see the xunit dll anymore, just new ones... xunit.core, xunit.assert etc... I think these are pre-release versions. Actually it seems to work now since xunit extensions version 1.8.0.1549 is still installed... so now I'm totally confused. I think I may just have to scrap this test project and start again – Aiden Feb 11 '15 at 16:28
  • It was my own stupidity, the app.config for some reason wasn't included in the project. Sorry for wasting your time. This question should probably be deleted? – Aiden Feb 12 '15 at 10:15
  • Glad to hear that you got your issue resolved :) – Mark Seemann Feb 12 '15 at 10:47

0 Answers0