Using a custom UnitTestProvider

Nov 6, 2012 at 11:23 AM

Hi,

 

I want to use the custom implementation of an UnitTestProvider from RavenDB (https://github.com/marwijn/Raven-Custom-Silverlight-Unit-Test-Provider) in my SL5 unit testing to be able to not use all the Enqueue stuff.

It's working fine when I launch the silverlight Test application but not under Resharper 7. I think it's because in the app.xaml.cs of the silvelright test application I have this code :

void Application_Startup(object sender, StartupEventArgs e)
{
    UnitTestProviders.Providers.Clear();
    UnitTestSystem.RegisterUnitTestProvider(new RavenCustomProvider());

    RootVisual = UnitTestSystem.CreateTestPage();
}

 

Is it possible to "tweak" in any way AgUnit so when I run my test from resharper I can specify this UnitTestProvider ?

 

thanks

Nov 6, 2012 at 11:38 AM

Hi nazbrok,

AgUnit doesn't know about unit test providers. For that it uses the StatLight library (http://statlight.codeplex.com/). AgUnit only bridges the gap between the R# unit test runners and the StatLight library.

StatLight doesn't run the Application_Startup code, instead it uses it's own application.

I guess you'll have to create a StatLight client specific for your unit test provider (like those many .xap files included with AgUnit, for example StatLight.Client.For.MSTest2011October.xap).

It's better that you contact @staxmanade, he knows everything about it.
You can also discuss this on the Github or Codeplex pages of StatLight.

Greetings,

Steven

Nov 6, 2012 at 11:47 AM

Here's a discussion about the same topic on the StatLight discussion board:

http://statlight.codeplex.com/discussions/243555

Nov 6, 2012 at 2:43 PM

I will have a look,

 

Thank you.

Nov 6, 2012 at 5:04 PM
Edited Nov 6, 2012 at 5:05 PM

Hey Nazbrok,

Could you try running StatLight against your test xap without agunit? If you look at the StatLight docs http://statlight.codeplex.com/documentation one of the command line parameters is --OverrideTestProvider. If you give it a value of "MSTestWithCustomProvider" it should work for your scenario. However I'm not sure if there will be a way for AgUnit to easily hand that value to StatLight... Hope this helps (a little).

Nov 6, 2012 at 8:00 PM

I just wrote a post on statlight forum about this, I didn't see your answer.

Well I was hoping modifying one of those xap (even if the solution looks a little bit ugly) could do the trick. Using the command line parameters will do the same as launching the test from the original silverlight unit testing application, I won't be able to test a specific method only as I can thru Resharper.

 

Looking at the code, I "think" maybe if I add this test in the  StatLight.Core.WebServer.XapInspection.TestFileCollection.DetermineUnitTestProviderType method it should do the trick

if (zipEntry.FileName.ContainsIgnoreCase("raven.tests.silverlight.unittestprovider"))
     return UnitTestProviderType.MSTestWithCustomProvider;


I will give a try

.

Nov 6, 2012 at 8:34 PM
Edited Nov 6, 2012 at 9:03 PM

it worked !!

 

Other possibility (without editing the code), rename the plugin in my application to XUnitContrib.Runner.Silverlight so it will use the MSTestWithCustomProvider.

 

Maybe it's you should add a pattern to identify all the CustomProvider and not only xunitcontrib

Nov 6, 2012 at 9:23 PM

The StatLight command is designed to let you give a command line argument for this scenario "--OverrideTestProvider". However I see how it's a bit more difficult with AgUnit in this scenario.

Couple possible approaches.

  • Does AgUnit hook into the ReSharper settings now? (Maybe add a setting here?)
  • Like you suggest, maybe a naming convention at the dll level?
  • The scope of projects doing custom Silverlight is getting smaller (from what I can tell) and the number who do tests is smaller than that, let alone the ones who want to go out and use custom test providers... so the audience is so small, maybe we just hack in the common providers like Ravens?

Other thoughts or suggestions?

Nov 6, 2012 at 10:06 PM

I've been planning to create a R# settings screen for AgUnit for quite a while, but never got around to doing so.
As you've mentioned Silverlight use is decreasing rapidly. At work we do all new development in html.
AgUnit is on maintenance mode for me personally, just to keep it working with the new versions of tools (VS, R#, ...).

I don't know of any custom test providers other than this Raven one, so I think just hardcoding it is not a big problem.

If all custom providers implement a certain interface, why not do detection based on that ?
If there's any Type that implements 'IUnitTestProvider', assume to use that ? 

 

Nov 7, 2012 at 8:43 AM

I also think the hardcoded solution is probably the best one since like you all said there is very few (if not only one) custom test provider out there for silverlight.