Unit Test succeeds, but Load Test always fails in VSTS 2008
I have been working with data-driven unit tests in Visual Studio, which are great (see below).
When a unit test is run by itself, a separate application domain is created in the test process for each unit test assembly. There is some overhead associated with marshalling tests and test results across the application domain boundary, so when running unit tests in a load test, the application domain is not created by default. This provides some performance boost in terms of the number of tests per second that the test process can execute before running out of CPU. The only drawback is that if the unit test depends on an app.config file, this doesn’t work without creating the app domain. In this case, you can enable the creation of app domain for the unit tests: in the Load Test editor’s Run Setting’s properties set the property “Run unit tests in application domain” to True.
[DataSource("System.Data.SqlClient",
"Data Source=(local);Initial Catalog=MY_DATABASE;User ID=testuser;Password=testuser",
"_Test_Values", DataAccessMethod.Sequential), TestMethod]
public void GetDataDatasourceRunSvc()
{
MyService target = new MyService();
RequestContract args = new RequestContract();
ResponseContract actual = null;
try
{
// Set variables from the datasource
// **************************************************************
string correlationID = TestContext.DataRow["CorrelationID"].ToString();
...
// Run unit test
// **************************************************************
actual = target.GetDataList(args, dataAccess);
}
catch (System.Exception ex)
{
Logging.Instance.Write(LogOutput.Xml, ex);
}
Assert.AreNotEqual(0, actual.Data.Count);
}
Monday, June 02, 2008 3:52:12 PM
|