notes from a passionate developer





This is a personal blog. The opinions expressed here represent my own and not those of my employer, nor current or previous. All content is published "as is", without warranty of any kind and I don't take any responsibility and can't be liable for any claims, damages or other liabilities that might be caused by the content.

How a Windows store lib made me go from NUnit to MSTest to xUnit

Not to long ago I wrote this post: “Why I gave up on NUnit and not went with something cool like XUnit

In that post I wrote:

I’m guessing though, that this will come back and bite me, and you will probably see a follow up post on this where I have switched testing framework.

And here we are!

The reason I first switched was that the test runners I used for NUnit, could not handle Windows store apps properly. So if you e.g. access the filesystem to read a file, that app needs to be hosted in its own app-container. If not, you will see something like this:

The process has no package identity

So I switched to MSTest just to get it to work. With ReSharper 8, I sometimes got a freeze with running those tests, but they are aware of the situation and are working on fixes. The builtin Test explorer introduced with Visual Studio 2012 could handle it, but me and that explorer are not best friends. I like the ReSharper test runner. I’m used to it’s shortcuts etc. Furthermore, when running the tests, it sometimes crashed all my tests in all my test projects. The setup is three unit tests projects and three integration tests projects, reusing files via “Add as link”, to get them to belong to different projects that targets different frameworks. I had the same issue with the new vstest.console.exe used in my build script. And this inconsistent behavior, along with MSTests static class initialization attributes; its different namespacing between non Windows store test projects and “plain” test projects made me switch again. This time for xUnit.

Welcome xUnit

Lets be clear. It’s not perfect (yet), but it gives me “one” testing framework with consistent namespaces. It gives, in my taste, a better setup and tear-down experience. But more importantly: It is consistent in its behavior. With that said, it does not mean everything is consistent cross context. The plugin for the Visual Studio Test explorer does host the Windows store test project in its own app-container, hence the tests that accesses the file system, works. How-ever, the current xUnit console does not, nor does the current ReSharper 8, xUnit test runner plugin. But within each context, it works/fails consistently. So for know, and with the knowing that there are people aware of the issues and working on it, I feel satisfied with xUnit and you will not see a followup on this post stating: “I switched again”.



View Comments