Tài liệu Mb Unit Test, Automation Unit Test, Test Driven Design (file ppt) pptx

18 762 7
Tài liệu Mb Unit Test, Automation Unit Test, Test Driven Design (file ppt) pptx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Trinh Minh Cuong Microsoft Vietnam  Unit Test: lập trình viên viết chương trình xong rồi tự test lại theo một số trường hợp cơ bản mà anh ta định ra.  Not Unit Test: lập trình viến viết mã, tester chịu trách nhiệm test. Unit Test vs Non Unit Test Anh code Anh code quá t !ệ quá t !ệ Cô testtest thi u ế thi u ế tr ng ườ tr ng ườ h p !!@@#ợ h p !!@@#ợ Manual Unit TestTest Driven Design  Manual Unit Test:  Tiết kiệm 1 ít thời gian lúc đầu.  Lập trình viên nhớ được case nào thì test.  Càng đến cuối dự án, số lượng test case tăng lên, khả năng bao quát các khả năng của lập trình viên giảm xuống.  Phải văn bản hóa các test case ra Word, Excel. Phần mềm phức tạp lên, văn bản test case nhanh chóng bị lạc hậu -> trở nên vô dụng.  Test Driven Design  Viết code đến đâu, thì viết test logic, test case bằng mã lệnh.  Hướng lập trình viên tư duy: viết code để chạy được và test được.  Sử dụng chương trình tự động duyệt qua tất cả test case rồi test. Xem thêm ở đây http://www.agiledata.org/essays/tdd.html There were many instances of machine-smashing, particularly in 1811- 1812 by a group calling themselves the Luddites [Luddites: A group of English workers who formed in the early 19th Century. They opposed and destroyed new textile machines which threatened their traditional jobs. Không phải ai cũng thích tự động hóa. Hình trên, công nhân Anh phá máy dệt vào đầu thế kỷ 19. Test Driven Design Documentation in TDD  Văn bản thiết kế, test case luôn luôn không đồng nhất với mã nguồn. Chúng có thể mới hơn, sai khác và lạc hậu so với mã nguồn.  Mã nguồn phản ánh trung thực nhất tình trạng, tiến độ của phần mềm. Tuy nhiên mã nguồn chưa chắc mô tả đầy đủ mục đích, tính năng của phần mềm cần lập trình.  TDD bám sát mã nguồn hiện có để test.  TDD đảm bảo:  Code viết ra, thêm mới được test lặp đi lặp lại theo những test case đề ra.  Module, function mới không tạo hiệu ứng phụ với code cũ.  TDD không chắc chắn đảm bảo:  Bao tất cả test case cần có.  …. Integration Testing Tại sao vẫn cần Integration Testing khi đã có automation unit test (test driven design) Integration Test:  Ideally written by a tester, however generally written by a developer.  Unhappy scenarios  End-To-End scenarios  Does the code meet customer requirements MbUnit – About the project  Open source project since 2004, see CodeProject.com  Created by Jonathan de Halleux.  Maintained by strong group of 12 people  “Unit Testing on crack” Scott Hanselman  Used on large scale projects  SubSonic  Rhino Mocks  SubText  http://www.mbunit.org  http://weblogs.asp.net/astopford Giới thiệu về MbUnit  http://www.mbunit.org  http://weblogs.asp.net/astopford http://www.mbunit.org http://weblogs.asp.net/astopford Hướng dẫn thực hành  Download MbUnit ở đây http://mb-unit.googlecode.com/files/MbUnit-2.4.2.130-Setup.exe  Mở solution XLINQ1, xem project TestXLINQ  XLINQ references đến MbUnit.Framework và XLINQ1 (project cần test) [...]... XLINQ1; //Dự án cần test using MbUnit.Framework; //Thư viện MbUnit.FrameWork bắt buộc phải có namespace TestXLINQ { [TestFixture] public class TestXLINQ { [SetUp] //Chuẩn bị dữ liệu, khởi tạo đối tượng cần test public void prepareTest() { } [Test] //Hàm test public void test_ FunctionA() { } [Row(8)] //Bộ giá trị truyền vào hàm test [Row(11)] [RowTest] public void test_ FunctionB (double testPrice) { } [TearDown]... [TearDown] //Dọn dẹp sau khi test public void TearDown() { } } } Giải thích class attribute ở MbUnit MbUnit Attributes Purpose [Test] Indentifies of an individual unit test [RowTest] For a single test, but with multiple different sets of data to execute a test against Each set of data is then executed separately as a unique test [TestFixture] Identifies of a group of unit tests, all Tests, and Initializations/Clean... trình test Báo cáo kết quả test DEMO Tham khảo  Articles: http://www.codeproject.com/KB/architecture/gunit.aspx http://www.codeproject.com/KB/architecture/jdhcompositeunitt esting.aspx http://www.codeproject.com/KB/dotnet/Tutorial_Extending_M bUnit.aspx  Books  xUnit Test Patterns – Gerard Meszaros  The Art of Unit Testing - Roy Osherove  Tools      MbUnit and Gallio – www.MbUnit.com TestDriven.Net... appear after this declaration [TestFixtureSetUp] Identifies a method which should be called a single time prior to executing any test in the Test Class /Test Fixture [TestFixtureTearDown] Identifies a method in to be called a single time following the execution of the last test in a TestClass/TestFixture [SetUp] Identifies a method to be executed each time before a TestMethod /Test is executed [TearDown]... each time after a TestMethod /Test has executed Cách báo lỗi khi test   Assert Throw exception if (Convert.ToDouble(cd.Element("PRICE").Value) . cả test case cần có.  …. Integration Testing Tại sao vẫn cần Integration Testing khi đã có automation unit test (test driven design) Integration Test:  Ideally. thích class attribute ở MbUnit MbUnit Attributes Purpose [Test] Indentifies of an individual unit test [RowTest] For a single test, but with multiple different

Ngày đăng: 24/01/2014, 01:20

Từ khóa liên quan

Mục lục

  • MbUnit Test Automation Unit Test Test Driven Design

  • Unit Test vs Non Unit Test

  • Manual Unit Test – Test Driven Design

  • Slide 4

  • Test Driven Design

  • Documentation in TDD

  • Integration Testing

  • MbUnit – About the project

  • Giới thiệu về MbUnit

  • Hướng dẫn thực hành

  • Slide 11

  • Slide 12

  • Giải thích class attribute ở MbUnit

  • Cách báo lỗi khi test

  • Giao diện chương trình test

  • Báo cáo kết quả test

  • DEMO

  • Tham khảo

Tài liệu cùng người dùng

Tài liệu liên quan