Month: August 2014

Now Shipping: xUnit support for Windows 8 and Windows Phone App 8.1

August 11, 2014 Coding 2 comments , ,

After years of unofficial hacks to get xUnit working for Windows Store apps, I’m happy to announce that xUnit v2 beta 4 ships with official support. As an added bonus, Windows Phone App 8.1 support is included as well.

To use xUnit for Store, you need the latest xUnit.net runner for Visual Studio installed.

Steps to create a Windows 8 Store Unit Test for xUnit:

  1. Install the runner
  2. Create a new Windows Store Unit Test project
  3. In the project references, remove the MSTestFramework reference and delete the UnitTest1.cs sample test
  4. Use NuGet to Install-Package xunit -Pre and install at least version 2.0.0-beta4-build2738
  5. Create your tests
  6. When you compile, you’ll see the tests in the Test Explorer window (make sure to show that window if it’s not visible)

Steps to create a Windows Phone App Unit Test for xUnit:

  1. Install the runner
  2. Create a new Windows Phone App Unit Test project (not Windows Phone 8.1 Silverlight)
  3. In the project references, remove the MSTestFramework reference and delete the UnitTest1.cs sample test
  4. Use NuGet to Install-Package xunit -Pre and install at least version 2.0.0-beta4-build2738
  5. Create your tests
  6. When you compile, you’ll see the tests in the Test Explorer window (make sure to show that window if it’s not visible)

To Do

  • Windows Phone 8 support – technical issues to overcome
  • Project Templates

Limitations

Right now, only Any CPU/x86 is supported by the VS Runner due to limitations in the VS Runner’s extensibility model. We plan on shipping a device runner, similar to the Xamarin Runner that will enable on-device ARM testing.

I’d like to thank @bradwilson and @jamesnewkirk for their patience and persistence with merging these large pull requests and keeping the release bar so high.

Announce: Ninject for Xamarin (and everything else)

August 4, 2014 Coding 2 comments , , ,

I’m happy to announce Ninject support for Xamarin.iOS and Xamarin.Android. Together with the previous release, which included support for Universal Apps, Ninject now supports every major platform in a single Portable.Ninject NuGet package.

Not being enough to simply support each platform, the Portable.Ninject package includes a Portable Class Library (PCL) reference assembly so you can reference Ninject in your PCL’s. Just make sure to also add the NuGet reference to your main application so the “real” bits get used instead of the reference assemblies. This means it’s easy to have NinjectModule‘s in your portable code.

For more documentation, please visit the Dojo or the Wiki.

To get started

  1. Add the Portable.Ninject package to your project.
  2. If your project is a PCL, also add the package to your main app.
  3. Somewhere in your main app, usually your App class (Windows), AppDelegate (iOS), or Application class (Android), create the Kernel and load your types/modules.

Limitations

This package just has the core Ninject functionality. Much of Ninject’s power comes from its extensions, including Convention Based Binding and Factory. These extensions have not yet been forked and updated to work with Portable.Ninject, but they shouldn’t be hard to do. Please drop a note to let me know which extensions you’d like to see brought over.

Contributing

Contributions are very much welcome! Please clone/fork my repo and use the bait-switch branch as your starting point. The solution contains unit test projects for all platforms; to run the xUnit ones for Wpa81 or Win8, you’ll need the latest xUnit runner for Visual Studio extension installed too.