Using xUnit.net AutoRollback and Multi Threading

I am trying to write a test case using xUnit.net and the AutoRollback attribute provided by xunit extensions.

My test case is as follows

[Fact, AutoRollback]<br>
public void TestCase()<br>
{

    // insert into data table
    repository.Insert(data);

    // spawn a new thread and read data which you just inserted in the data table
    Task.Factory.StartNew(action_to_read_data);
}

This test case crashes and throws a connection timeout exception while reading data in a new stream. The problem I discovered is that the test script starts the transaction due to the AutoRollback attribute and, inserting the data, it locks the table for rollback at the end. The new thread generated by the test case cannot read data from one table, because it is blocked by the parent thread. I can read data in the same stream.

Anyone have a solution? I want to start multiple threads by reading the data inserted above.

+3
1

, , , , unit test, AutoRollback. , .

+1

All Articles