Statlight runs 1st test method multiple times


Go vote up this one... http://silverlight.codeplex.com/workitem/7143
My test method gets called twice by statlight. The following code is a very simple repro:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace StatlightDoubleRunRepro
public class Tests
    static int calls = 0;
    public void TestMethod1()
        Console.Out.WriteLine("Calls = {0}", calls);
Any idea how I can prevent this?

file attachments

Closed Feb 11, 2012 at 6:22 AM by staxmanade
In the following commit https://github.com/staxmanade/StatLight/commit/89f70fc3dd7bbaea628c5807e094592a55278bd1I think it's been fixed. From what I can tell.


staxmanade wrote Sep 9, 2010 at 8:33 PM

At this point no. I think it's a bug in the Microsoft.Silverlight.Testing framework relating to how StatLight configures the settings http://github.com/staxmanade/StatLight/blob/master/src/StatLight.Client.Harness.MSTest/MSTestRunnerHost.cs#L74

It was introduced in more recent versions of the MSTesting framework - requiring me to add a bunch of back end duplicates detection code to StatLight web server end.

Would love to hear about any other clues you have...

wrote Sep 10, 2010 at 8:59 AM

robfe wrote Sep 10, 2010 at 8:59 AM

I've uploaded a diff of the two stacktraces of each method call. It does look like the ms test runner has been configured strangely

robfe wrote Sep 10, 2010 at 9:22 AM

It also looks like it's only the first test being run twice, and if you put an ignore attribute on the test, then statlight counts it twice (whereas if it passes, then statlight counts it once but runs it twice)

staxmanade wrote Sep 10, 2010 at 2:32 PM

I was able to reproduce it (without StatLight). It a Microsoft specific bug. If you comment/uncomment the StartRunImmediately line below you can see the bug show/not show...
        var settings = new UnitTestSettings();
        settings.TestHarness = new UnitTestHarness();

        settings.StartRunImmediately = true;

        this.RootVisual = UnitTestSystem.CreateTestPage(settings);

staxmanade wrote Sep 10, 2010 at 2:41 PM

robfe wrote Sep 10, 2010 at 3:47 PM

nice work. I'll try and and garner some votes :)

wrote Sep 26, 2010 at 10:19 PM

wrote Jan 10, 2011 at 10:20 AM

aviade wrote Jan 10, 2011 at 10:30 AM

The is especially a problem with asynchronous tests, the second run start before the first run ends. This is a major issue since it makes tests that use global state (like Singletons) impossible to run. Any ideas when this problem is going to be resolved?

Thanks ,Aviad

wrote Feb 10, 2011 at 3:47 PM

wrote Feb 10, 2011 at 8:05 PM

wrote Mar 2, 2011 at 12:48 AM

EVM wrote Feb 10, 2012 at 4:55 AM

GDay guys,

look my post here, maybe this will work for you


wrote Feb 11, 2012 at 6:22 AM

wrote Feb 14, 2013 at 9:18 PM

wrote May 16, 2013 at 10:50 AM