Problem with MSTest and Resharper test runner

We are running a set of intergration tests that uses TransactionScope to rollback the database after each test. After installing R#6.0 several tests suddenly have begun to fail when running the test assembly with the test runner. It seems like that the database isn't rolling back anymore. When running each test class independently it rolls back. This worked fine with R# 5.1. Running the tests from the mstest command line still works fine.

Has anyone experienced something like this?

Thanks.

9 comments

Hello Goran,

How do you invoke TransactionScope rollback in your tests? Could you please
attach a small sample solution that would demonstrate this behavior? Thank
you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

We are running a set of intergration tests that uses TransactionScope
to rollback the database after each test. After installing R#6.0
several tests suddenly have begun to fail when running the test
assembly with the test runner. It seems like that the database isn't
rolling back anymore. When running each test class independently it
rolls back. This worked fine with R# 5.1. Running the tests from the
mstest command line still works fine.

Have anyone experienced something like this?

Thanks.

---
Original message URL:
http://devnet.jetbrains.net/message/5308412#5308412



0

Generally like this:

     private TransactionScope _transactionScope;

        [TestInitialize]
        public void Setup()
        {
            _transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew);
            _dal = new SomeDal();

        }

        [TestCleanup]
        public void TearDown()
        {
         _dal.Dispose();
         _transactionScope.Dispose();
        }




     ...then some tests using the dal.
0

After doing some logging we have seen that the SqlConnection is enlisted in the transaction when i run test classes alone, but is NOT enlisted when i run the entire assembly.

0

Hello Gøran,

I'm afraid I wasn't able to reproduce this behavior. Do I understand correctly
that when you put a breakpoint inside the TearDown method and try debugging
your tests the breakpoint doesn't get hit? Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Generally like this:

private TransactionScope _transactionScope;


public void Setup()
{
_transactionScope = new
TransactionScope(TransactionScopeOption.RequiresNew);
_dal = new SomeDal();
}


public void TearDown()
{
_dal.Dispose();
_transactionScope.Dispose();
}
...then some tests using the dal.

---
Original message URL:
http://devnet.jetbrains.net/message/5308447#5308447



0

No, both Setup and TearDown get called. It's the connection for the dal that doesn't enlist in the current transaction. It does this only when I run the test class alone.

0

Hello Gøran,

When exactly is the sql connection created? At the moment when _dal = new
Dal() is invoked (in your previous example)? Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

No, both Setup and TearDown get called. It's the connection for the
dal that doesn't enlist in the current transaction. It does this only
when I run the test class alone.

---
Original message URL:
http://devnet.jetbrains.net/message/5308586#5308586



0

After some more debugging we found some tests that didn't dispose the connection, so now it's working. However, it is strange that it worked in R#5.1.

0

Hello Gøran,

The MSTest part of ReSharper's unit test runner has been rewritten since
ReSharper 5.1 in order to fix some problems, and the order in which tests
are being run might have changed. Anyway, I'm glad that you were able to
figure it out. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

After some more debugging we found some tests that didn't dispose the
connection, so now it's working. However, it is strange that it worked
in R#5.1.

---
Original message URL:
http://devnet.jetbrains.net/message/5308750#5308750



0

Please sign in to leave a comment.