G
Guest
Hello,
I am trying to set up some nested transactions to speed up a group of unit
tests. The unit tests call a common method to build up some test data, which
takes about 30 seconds and then runs a specific test. Each C# unit tests has
a using statement that creates a new new
TransactionScope(TransactionScopeOption.Required, timeSpan) (timeSpan is 600
seconds). Data access uses the Patterns and Practices Enterprise Library 2.0
against a SQL Server 2005 database.
It all works fine but I would like to speed up my total test time and only
create the test data once. I added [ClassInitialize()] and [ClassCleanup()]
methods to run when my unit tests start and end. In the ClassInitialize
method I created a TransactionScope(TransactionScopeOption.Required,
timeSpan) and in the ClassCleanup I added a transactionScope.Dispose(); In
each test, I created a TranactionScop(TransactionScopeOption.RequiresNew,
timeSpan) both with a duration of 5 minutes. Now I am getting a timeout
error.
"Error retrieving data for the query from command with CommandText of xxx:
Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding." (where xxx is a select stored
procedure name)
If I replace RequiresNew with Required in the individual tests, the first
test works and subsequent tests fail, which makes sense because it appears to
join and roll back the outer ambient transaction.
Does anyone know why nesting I would get the timeout at about 30 seconds
with the RequiresNew?
Thanks,
David Morris
I am trying to set up some nested transactions to speed up a group of unit
tests. The unit tests call a common method to build up some test data, which
takes about 30 seconds and then runs a specific test. Each C# unit tests has
a using statement that creates a new new
TransactionScope(TransactionScopeOption.Required, timeSpan) (timeSpan is 600
seconds). Data access uses the Patterns and Practices Enterprise Library 2.0
against a SQL Server 2005 database.
It all works fine but I would like to speed up my total test time and only
create the test data once. I added [ClassInitialize()] and [ClassCleanup()]
methods to run when my unit tests start and end. In the ClassInitialize
method I created a TransactionScope(TransactionScopeOption.Required,
timeSpan) and in the ClassCleanup I added a transactionScope.Dispose(); In
each test, I created a TranactionScop(TransactionScopeOption.RequiresNew,
timeSpan) both with a duration of 5 minutes. Now I am getting a timeout
error.
"Error retrieving data for the query from command with CommandText of xxx:
Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding." (where xxx is a select stored
procedure name)
If I replace RequiresNew with Required in the individual tests, the first
test works and subsequent tests fail, which makes sense because it appears to
join and roll back the outer ambient transaction.
Does anyone know why nesting I would get the timeout at about 30 seconds
with the RequiresNew?
Thanks,
David Morris