Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Unit test demo for calculatechinesenamenumber

298 views

Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Unit test demo for calculatechinesenamenumber

  1. 1. Unit Test 姓名學最佳筆畫數為例 Author : Juggernaut Liu
  2. 2. Outline ● Testing framework ● Project Introduction ● Implement Process ● Demo ● Notes ● Reference
  3. 3. Testing framework ● Coding ○ c++ ● Googletest ○ https://code.google.com/p/googletest/ ● Googlemock ○ https://code.google.com/p/googlemock/
  4. 4. Project Introduction ● 姓名學 - 如何取名 ○ http://juggernaut-liu.blogspot.tw/2013/09/rule-1-rule-2-1-2-rule-3-15-x- 6-15-x-6.html ● Project Scope ○ Input : 姓筆畫, 缺五行type ○ Rules: ■ 總格補上缺乏的五行 ■ 三才配置 ■ 八十一數之靈動 ○ Ouput: 用vector存的最佳筆畫數組合
  5. 5. Project Introduction(2) ● CalculateChineseNameProcessor ○ main algorithm ● UnitTest ○ unit test for CalculateChineseNameProcessor
  6. 6. Project Introduction(3) CalculateChineseNameProcessor ● NameProfile ○ Data structure ● ILoadSettings ○ Loading config from text ● IDataProducer ○ Produce initial data (A lot of NameProfile) ● IRulefilter ○ Each Rulefilter filter out not-matching NameProfiles ● MainProcessor ○ Run all process
  7. 7. Project Introduction(4) class diagram
  8. 8. Implement Process Steps 1, Design one Interface 2, Write the Unit Test 3, Write the production code 4, Modify interface or test to match the code. 5, Repeat 1,2,3,4 to next feature.
  9. 9. Implement Process(2) Implement order 1, NameProfile 2, IDataProducer 3, IRuleFilter 4, ILoadSettings 5, MainProcessor
  10. 10. Demo
  11. 11. Notes ● I do not test private code, but I test the public code which call private code ● TEST vs TEST_F ● SetUpTestCase, TearDownTestCase vs SetUp, TearDown ● ::testing::FLAGS_gtest_output = "xml:" =>log
  12. 12. Notes(2) ● Each unit test pass the test, but it test error when I combine them ○ Got 1 bug ● Test sample is too few to test all conditions ○ Miss some conditions
  13. 13. Reference GitHub https://github.com/JuggernautLiu/CalculateChineseNameNumber MyBlog http://juggernaut-liu.blogspot.tw/2013/09/rule-1-rule-2-1-2-rule-3-15-x-6-15-x-6. html Googletest https://code.google.com/p/googletest/ Googlmock https://code.google.com/p/googlemock/

×