2

I have a bunch of tests in an assembly. These tests all live in [TestClass] classes and are marked with a [DataSource] pointing to Sql Server. Each of these test classes extends a BaseTest also marked with [TestClass]. I have an [AssemblyInitialize] method in BaseTest that creates the view on the server for DataSource to use (I'd kill to be able to use a tvf instead). This works fine when the tests run through MTM. As of a few weeks ago it stopped working locally - Init isn't being called until AFTER DataSource loads (manually created my_view, traced the server, put a breakpoint on Init() and didn't hit the breakpoint until after I saw the test do a SELECT * FROM [my_view]).

Overview of code:

[TestClass]
MyTests : BaseTest
{
    [TestMethod]
    [DataSource("..SqlClient",CONN,"my_view",..Sequential)]
    public void MyTest(){}
}

[TestClass]
BaseTest
{
    [AssemblyInitialize]
    public static void Init(TestContext testContext){//create my_view}

    [AssemblyCleanup]
    public static void Cleanup(){//drop view}

    [TestInitialize]
    public void TestInit(){}

    [TestCleanup]
    public void TestCleanup(){}

}

Things I've tried to no avail:

  1. Adding a [TestMethod] to the BaseTest
  2. Putting [AssemblyInitialize] in MyTests
  3. Ensuring there is only one [AssemblyInitialize]
  4. Running in VS 2013 instead of 2015
  5. Running with Keep Test Execution Engine running on and off
allie
  • 369
  • 1
  • 15

0 Answers0