1 / 26

Automated Unit Testing

Automated Unit Testing. Agenda. Software testing levels Manual unit testing Unit Testing based on UT cases Automated Unit Testing Automated Unit Testing with CPPUnit. Too many of Software Testing Levels. How we test this function?. Requirement :

candra
Download Presentation

Automated Unit Testing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Automated Unit Testing

  2. Test Driven Development and Code Coverage Agenda • Software testing levels • Manual unit testing • Unit Testing based on UT cases • Automated Unit Testing • Automated Unit Testing with CPPUnit

  3. Too many of Software Testing Levels

  4. How we test this function? Requirement : - Write a module to add an User to DataBase Business rule : - Email can not be duplicated - Email must be in valid form - UserName ‘s length must be > 8 - UserName can not be dupplicated - Password length must be > 8

  5. Creative Commons Attribution Share-alike Manual Unit Testing • Write code • Uploading the code to some place • Build it • Running the code manually (in many cases filling up forms etc step by step) • Check Log files, Database, External Services, Values of variable names, Output on the screen etc • If it does not work, repeat the above process

  6. Manual Unit Testing - Limitation • Developer nhớđượctrườnghợpnàothì test trườnghợpđó • Đếncuốidựánsốlượng test case cànglúccàngnhiều, khảnăng cover củalậptrìnhviêngiảmxuống! • Nhiều test case bịtrùnglắp • Nhiều test case bị lack • Team lead khôngthể review hếtđược •  Kếtquảdựánchỉtrôngchờvào tester!!!! •  Rấtnhiềulỗiphátsinhsaukhi system test, đaphầncáclỗixuấtphát do Dev test khôngkỹtừlúc Unit Test!

  7. Unit Testing based on UT cases • ĐểgiảiquyếtvấnđềtrênMỗikhi developer test xongphảiviếttàiliệumôtả test case trên word hoặc excel ! • Điềunàygiúp team rấtdễdàng review.. Tuy nhiên, cáchlàmnàysẽphátsinhrarấtnhiềuhạnchế!

  8. Unit Testing based on UT cases • Cácdựánlớnthìsốlượngtàiliệu test case thườngcũngrấtlớn! • Cácdựánlớnthì requirement thường hay thayđổi • Mỗikhi requirement thayđổi Phảisửa code phảicậpnhậtlạitàiliệutestcase vàlại manual retest , rấttốneffortCàngđếncuốidựán, lượngviệcsinhracàngnhiều , viết test case document trởthành “địangục “ thựcsự ! dev khôngcònđủ effort update test case document, tàiliệunhanhchóngbịlạc hậu, hoặcviệc update chỉlàđốiphó! • Mộtsốtrườnghợpkhôngthểdùng Excel Unit TestCase So, what is the solution?

  9. Creative Commons Attribution Share-alike Automated Unit TestingFirst Step • Coding Process with Automated Unit Tests • Write code • Write one or more test cases script • Auto-compile and run • If tests fail -> make appropriate modifications • If tests pass -> repeat for next method

  10. Creative Commons Attribution Share-alike Automated Unit TestingFirst Step DEMO

  11. Automated Unit Testing Common Tools • UT Tools for references: • Java: JUnit, J2MEUnit • C/C++: cppUnit • Python: pyUnit • Perl: PerlUnit • Visual Basic: vbUnit • C# .NET: Nunit,csUnit • Refferences: • http://www.testingfaqs.org/t-unit.html • www.junit.org • http://www.codeproject.com/gen/design/autp5.asp

  12. Automated Unit Testing Common Tools http://sourceforge.net/projects/cppunit/ http://www.nunit.org http://www.junit.org/

  13. Automated Unit Testing with CPPUnitWhat is CPPUnit? Milk ? Beer or Coffee? • CPPUnit– an open source test tool for C/C++ • Useful for development and regression • Leads to a design-for-test approach • Tests can be written in C/C++

  14. Automated Unit Testing with CPPUnitWhere to get CPPUnit? • Let’s go to website: http://downloads.sourceforge.net/cppunit/cppunit-1.12.1.tar.gz Yeahh, I got it

  15. Automated Unit Testing with CPPUnitCreate a test case • Step 1: Create a project C++ dạng console

  16. Automated Unit Testing with CPPUnitCreate a test case • Step 2: Create a Class Calculator códạngsau: • Step 3: build. Chươngtrìnhsẽbáolỗinhưbêndưới.

  17. Automated Unit Testing with CPPUnitCreate a test case • Step 4: Cấuhình Visual 2008 để build kolỗi.

  18. Automated Unit Testing with CPPUnitCreate a test case • Step 5: Add new empty project (Click phảichuộtvào Solution…/ Add / New Project). • ( Tạogiốngbước 1 )

  19. Automated Unit Testing with CPPUnitCreate a test case • Step 6: Tạonội dung củaTestCalculatorgiốngnhưsau:

  20. Automated Unit Testing with CPPUnitCreate a test case • Step 6: Tạonội dung củaTestCalculatorgiốngnhưsau:

  21. Automated Unit Testing with CPPUnitCreate a test case • Step 6: Tạonội dung củaTestCalculatorgiốngnhưsau:

  22. Automated Unit Testing with CPPUnitCreate a test case • Step 7: Set TestCalculator as startup project • Step 8: build. Chươngtrìnhsẽthôngbáolỗinhưsau. • Step 9: Cấuhình tool để build thànhcông. • Click chuộtphải project TestCalculatorchọn Properties • Chọn Configuration Properties/ C/C++/ General • Tạiphần Additional Include Directories: Chỉđếnđườngdẫn file nguồncủa project. (Hìnhdướiđây)

  23. Automated Unit Testing with CPPUnitCreate a test case • Step 10: re-build. Chươngtrìnhsẽthôngbáolỗinhưsau. • Step 11: Cấuhình tool để build thànhcông. • Tiếptheochọn Configuration Properties/ Linker/ Input • Tạimục Additional Dependencies, nhậpvào: cppunitd.lib • Tiếptheochọn “Release” tạicomboboxConfigration • Tạimục Additional Dependencies, nhậpvào: cppunit.lib • Click Ok đểhoàntất. • Re-bulid.

  24. Automated Unit Testing with CPPUnitCreate a test case • Step 12: F5 Note: Trong trườnghợp build khôngđượcvuilòngđọchướngdẫncách build CPPUnit ở thưmục : Huong Dan CaiDat. CóthểthamkhảocáchtạoCPPUnitdựatheoVideo_CPPUnitStepByStep.mp4

  25. Automated Unit Testing with CPPUnit DEMO CPPUnitis Number One.

  26. Test Driven Development and Code Coverage Q & A

More Related