2010年7月19日星期一

TDD & Unit Test

TDD Tests are not Unit Tests
http://stephenwalther.com/blog/archive/2009/04/11/tdd-tests-are-not-unit-tests.aspx

Unit testing with Visual Studio 2008
http://www.geekzone.co.nz/vs2008/4819

A Unit Testing Walkthrough with Visual Studio Team Test
http://msdn.microsoft.com/en-us/library/ms379625(VS.80).aspx

The first noteworthy characteristic of Listing 6 is the addition of the DataSourceAttribute in which the connection string, table name, and access order are specified. In this listing we use a database file name to identify the database. The advantage of this is that the file will travel with the test project, assuming it is updated to be a relative path.

The second important characteristic is the TestContext.DataRow calls. TestContext is a property that the generator provided when we ran the Create Tests wizard. The property is automatically assigned by the test execution engine at runtime so that within a test we can access data associated with the test context, As Figure 7 shows, the TestContext provides data such as the TestDirectory and TestName, along with methods such as BeginTimer() and EndTimer(). What is most significant for the ChangePasswordTest() method is the DataRow property. Because the ChangePasswordTest() method is decorated with DataSourceAttribute, it will be called once for each record returned from the table specified by the attribute. This enables the test code to use the data within an executing test and have the test repeat for each record inserted into the LogonInfoTest table. If the table contains four records, then the test will be executed four separate times.

没有评论:

发表评论