Download presentation
Presentation is loading. Please wait.
Published byWillis Briggs Modified over 9 years ago
1
MS Visual Studio 2005 Unit Test
2
Agenda Team system 概觀 Unit Test Code Coverage Web Test
3
Team System 概觀 Process and Architecture Guidance Visual Studio Industry Partners Dynamic Code Analyzer Visual Studio Team Architect Static Code AnalyzerCode ProfilerUnit TestingCode CoverageVisio and UML ModelingTeam Foundation Client (includes CAL)Visual Studio Professional EditionLoad TestingManual TestingTest Case ManagementApplication DesignerLogical Infra. DesignerDeployment Designer Visual Studio Team Developer Visual Studio Team Test Load TestingManual Testing Test Case Management Change ManagementWork Item TrackingReportingProject Site Visual Studio Team Foundation Integration ServicesProject ManagementBig BuildClass Designer
4
測試種類 Unit test Web test Load test Manual test Generic test Ordered test 3rd-party (NUnit, xUnit, …)
5
Unit Test Namespace Microsoft.VisualStudio.TestTools.UnitTesting Attributes TestMethod, TestClass, TestInitialize, TestCleanup, ClassInitialize, ClassCleanup, AssemblyInitialize, AssemblyCleanup
6
Using Microsoft.VisualStudio.TestTeels,unitTesting; [TestClass] Public class ShoppingCartTest { private ShoppingCart cart; [TestInitialize] public void TestInitialize() { …….. } [TestCleanup] public void TestCleanup() { ……… } [TestMethod] public void TestCountAfterAdd() { ……… } [TestMethod] public void TestCountAfterRemove() { …….. }
7
Attributes 執行時機不同 TestMethod 每次執行 Unit Test 都會 run TestInitialize, TestCleanup 每次 Unit Test 的初始和結尾 ClassInitialize, ClassCleanup Class Test 的初始和結尾 AssemblyInitialize, AssemblyCleanup 只執行一次,為最早及最後被呼叫的 attribute
8
Assert Methods Assert.AreEqual, Assert.AreNotEqual Assert.AreSame, Assert.AreNotSame Assert.IsTrue, Assert.IsFalse Assert.IsNull, Assert.IsNotNull Assert.IsInstanceOfType, Assert.IsNotInstanceOfType Assert.Fail, Assert.Inconclusive
9
CollectionAssert Class AllItemsAreInstanceOfType AllItemsAreNotNull AllItemsAreUnique AreEqual,AreNotEqual AreEquivalent,AreNotEquivalent Contains, DoesNotContain IsNotSubsetOf, IsSubsetOf
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.