unit-testingseleniumcastle-activerecordmicrosoft-test-managermtm

Unexplained Castle and MTM errors


I have a suite that runs a little over 30 tests through MTM. They're selenium tests and take a bit over 20 minutes to run. 6 of these tests are new (2 tests, 3 iterations each) to the project, and error out for the same reason every time they run.

Here's the catch: 1. They pass locally 2. They pass when run individually

The specific error is from Castle ActiveRecord telling me to initialize a class I have most definitely initialized in the code.

[TestMethod]
public void Test(){
    Initialize();
    //do test
}

public void Initialize(){
    if(!ActiveRecordStarter.IsInitialized){
        Type[] types = //typeof each castle class;
        InPlaceConfigurationSource source = new InPlaceConfigurationSource();
        //set up source
        ...
        ActiveRecordStarter.Initialize(source, types);
    }
}

Solution

  • MTM runs all the tests without restarting the assembly. If a Castle test runs before my failing tests, it will intialize ActiveRecordStarter, and keep it initialized through my tests. For some reason, my tests did not like this (no answer yet on why), but calling ActiveRecordStarter.ResetInitializationFlag(); before the IsInitialized check fixed the errors.