Nov 7, 2013

Microsoft.VisualStudio.TestTools.UnitTesting hints

My experience with Microsoft.VisualStudio.TestTools.UnitTesting.

Attributes [TestInitialize] & [TestCleanup] are executed after each test marked with [TestMethod].
So if you have test class like this:

[TestClass]
public class Test
{

[TestInitialize]
public void Initialize

[TestMethod]
public void GetIsAdAvailable_InvalidCampaignId_ShouldFail()

[TestMethod]
public void GetIsAdAvailable_ValidCampaignId_InvalidCampRange_ShouldFail()

[TestCleanup]
public void Cleanup()

}

If you run all tests here is execution flow:

Initialize

GetIsAdAvailable_InvalidCampaignId_ShouldFail

Cleanup

Initialize

GetIsAdAvailable_ValidCampaignId_InvalidCampRange_ShouldFail

Cleanup

No comments:

Post a Comment