xunitcontrib-silverlight 0.2 – Windows Phone 7 support

by Matt 16. March 2011 11:45

Fancy writing xUnit.net tests for Windows Phone 7?

image

I’ve just pushed the latest release of xunitcontrib-silverlight to codeplex. It’s version 0.2 and builds on the first release by including a Windows Phone 7 compatible provider for the Silverlight Unit Testing Framework.

Using it is dead easy, but not exactly seamless – check out this brilliantly helpful post for full details . In outline:

  1. Create a Windows Phone application project
  2. Add references to:
    • Microsoft.Silverlight.Testing (the Silverlight 3 version – included in the release package)
    • xunit-silverlight-wp7
    • xunit.extensions-silverlight-wp7
    • xunitcontrib.runner.silverlight.toolkit-wp7
    • (Visual Studio may decide to whinge about adding Silverlight 3 assemblies to a WP7 project. Ignore them, it’s all fine)
  3. In the MainPage.xaml.cs file, modify MainPage_Loaded to create the test page and set it as the RootVisual (see the above post for an example)
  4. VERY IMPORTANT: Register the xunit test provider. Simply call XunitContrib.Runner.Silverlight.Toolkit.UnitTestProvider.Register()
    If you fail to do this, NO TESTS WILL RUN
  5. Write some xunit tests and run the application

Everything else is pretty much as for the desktop (Silverlight) runner:

  • The core xUnit.net API is fully supported (Fact, Theory, new test instance per run, IUseFixture, IDisposable, etc)
  • ExclusiveAttribute works as a means of filtering which tests to run
  • Use traits with keys of “category”, “owner” and “description” to pass metadata into the system (not used much, but nice to know)
  • OleDb theories aren’t supported due to lack of Silverlight support. Similarly, capturing output
  • Tests aren’t run in random order (they’re run alphabetically)
  • Theory tests are enumerated in full before the tests are run, so there is a single test for each instance of a theory test combination. If enumerating tests is expensive, project startup will be expensive
  • Silverlight does not support private reflection. This means you might need to use InternalsVisibleTo for xunit-silverlight-wp7

GOTCHAS. There are a couple:

  1. The namespace displayed for a failing test is incorrect. It’s always displayed as “XunitContrib.Runner.Silverlight.Toolkit”. There is a change currently sitting in source control for the silverlight unit testing framework that will sort this out. Once the bits have been released, this will be fixed properly
  2. Don’t forget to call UnitTestProvider.Register!
  3. There is a bug in the xaml for the test page which makes the “Run everything” button invisible. This means that it looks like there’s only the “Use tag” button – and using this button causes the ExclusiveAttribute to be ignored (because you’ve specified what to run with a tag expression). The workaround is to just click it anyway (the yellow rectangle in the image below) – it still works, you just can’t see it. Similarly, this bug is fixed in source control, and will be rolled into a release once the official bits are released.

image

This release has a couple of other changes to the 0.1 release that are worth mentioning:

  1. Assemblies are now versioned appropriately. For the xunit files, the file version is the xunitcontrib version (e.g. 0.2) which is the value displayed in Windows Explorer. However, the internal version of the assembly (the number you link against), is set to the version of the xunit assembly
  2. The xunit assemblies have been renamed to follow a known pattern, namely *-silverlight3, *-silverlight4 or *-silverlight-wp7
  3. The xunit assemblies now come with xml intellisense docs

So what’s next?

  • Well, it’s getting painfully difficult to build from source. I think I’m going to have to bite the bullet and put the xunit port into its own fork
  • nuget support
  • Ensure support for the Silverlight Unit Test Framework’s base classes, which means ensuring asynchronous tests and the UI test panel work

And of course, anything else that get’s reported. Please list issues at codeplex, or ping me on twitter @citizenmatt.

Tags:

Comments (36) -

New york yankees Baseball cap
New york yankees Baseball cap
6/19/2011 3:04:08 PM #


I've learned a lot from your blog here,Keep on going,I will keep an eye on it,One more thing

Reply

AT&T Unlimited Plan
AT&T Unlimited Plan
7/15/2011 6:36:53 PM #

Very informative post. I have learned a lot about silverlight and windows 7.

Reply

best suv 2011
best suv 2011
7/20/2011 10:24:55 PM #

hi!,I like your writing so so much! proportion we communicate extra about your post on AOL? I require a specialist in this area to unravel my problem. May be that's you! Taking a look forward to see you.

Reply

iphone developer program
iphone developer program
7/24/2011 6:07:30 AM #

Fantastic task I like your type! Would really like to right here your feedback on my website! I am also seeking for someone to help you me make websites!

Reply

Grönt te koffein viktminskning
Grönt te koffein viktminskning
9/2/2011 9:04:39 AM #

Very Interesting. Is there any more information on the topic?

Reply

iphone 5
iphone 5
10/2/2011 4:47:41 AM #

That is interesting and really helped me clarify some aspects, thanks.

Reply

cheap home phone service
cheap home phone service
10/15/2011 12:24:05 PM #

Windows phone 7 is a great product. If only more people would try it.

Reply

Lisa
Lisa
10/22/2011 8:29:25 PM #

hi,

Nice, post here may come back soon
Keep like this

Reply

Oren Tim
Oren Tim
10/27/2011 7:00:51 PM #

Nice Infomation, I was looking for this

Reply

toilet paper coupons
toilet paper coupons
10/29/2011 3:20:16 AM #

It is what I've search for several month

Reply

Greitos paskolos
Greitos paskolos
11/5/2011 6:41:29 AM #

great info here, I was looking something like that about windows 7

Reply

konkursy
konkursy
11/11/2011 2:47:02 AM #

It’s not that I want to copy your web-site, but I really like the design. Could you tell me which design are you using? Or was it especially designed?

Reply

Reparar Ordenadores
Reparar Ordenadores
11/11/2011 5:07:35 AM #

Nice Infomation.

Thank you Smile

Reply

dinosaur bedding
dinosaur bedding
11/11/2011 8:01:39 AM #

window phone 7 is the best.. great app
http;//dinosaurbeddingsite.blogspot.com/

Reply

whizzy
whizzy
11/11/2011 8:11:20 AM #

wish to learn ethical hacking from the experts ? www.infysec.com/.../certified-ethical-cracker

Reply

sohbet
sohbet
11/11/2011 9:20:46 AM #

Very informative post and fine blog !

Reply

mirc
mirc
11/11/2011 9:24:06 AM #

Now the computer will shut down the transfer of touchscreen phones, such as I think everything will take place

Reply

mirc
mirc
11/11/2011 9:25:25 AM #

I think the product xunitcontrib tekonoloi Silverlight 0.2 - Windows Phone 7 support

Reply

chat
chat
11/11/2011 9:28:03 AM #

What is the percentage strength of this product, I wonder?

Reply

ollete
ollete
11/12/2011 12:02:56 AM #

nice post...  thanks for information...

Reply

uggs
uggs
11/16/2011 2:25:51 PM #

I would name your blog the dreamland! While Santa knocks at our door just once per year, you blog is open the whole year - wow!<a href="http://www.uggsale.be">uggs</a>;

Reply

curiozitati cultura generala
curiozitati cultura generala
11/17/2011 2:45:23 AM #

I realizeeverything you've done here! amazing content

Reply

Gain weight build muscle
Gain weight build muscle
11/17/2011 3:06:47 AM #

Great tutorial & instructions! Thank you.

Reply

Lojas de Pianos
Lojas de Pianos
11/18/2011 1:26:55 AM #

this must be awesome, when i have some money i´ll try one.. thank´s for sharing.

Reply

Domantas
Domantas
11/18/2011 10:25:49 AM #

Nice tutorial.Thanks!

Reply

Ls 2011 mods
Ls 2011 mods
11/18/2011 10:34:47 AM #

Thanks for article buddy.

Reply

Houston Pet Sitting
Houston Pet Sitting
11/18/2011 2:02:51 PM #

Awesome article. Thank you for posting this.

Reply

Greg
Greg United States
11/20/2011 8:53:03 PM #

Your method of telling all in this post is genuinely nice, every one be able to simply know it, Thanks a lot.

Reply

Uggs kopen
Uggs kopen
11/21/2011 1:27:30 PM #

I just required some information and was searching on Google for it. I visited each page that came on first page and didn’t got any relevant result then I thought to check out the second one and got your blog. This is what I wanted!<a href="http://www.uggskopensale.nl">Uggs kopen</a>

Reply

uGG boots cheap sale
uGG boots cheap sale
11/24/2011 1:18:00 PM #

Thank you for this article. That’s all I can say. You most definitely have made this blog into something special. You clearly know what you are doing, you’ve covered so many bases.Thanks!
<a href="http://www.uggsuksale.org.uk">uGG boots cheap sale</a>

Reply

Pingbacks and trackbacks (1)+

Add comment

biuquote
  • Comment
  • Preview
Loading

Rel=Me

Month List

RecentComments

Comment RSS