Download presentation
Presentation is loading. Please wait.
Published byChristopher Carter Modified over 9 years ago
1
Embedded Systems Software Training Center Unit Testing Workshop Copyright © 2012 DSR Corporation
2
Objectives Implement unit tests and complete unit- testing procedure on existing code from previous workshops. Copyright © 2012 DSR Corporation 2
3
Agenda 1. Problem definition 2. Action items 3. Implementing unit-test technique 4. Code coverage analysis Copyright © 2012 DSR Corporation 3
4
Embedded Systems Software Training Center Problem definition Copyright © 2012 DSR Corporations
5
Problem definition Copyright © 2012 DSR Corporation Foundations of Software Testing. ISTQB Certification. Dorothy Graham, Erik Van Veenendaal 5 Task: Perform unit-testing procedure on existing code of bluetooth file transfer application. Deliviries: State diagram State transition matrix Source code (with implemented unit tests) Unit tests results Code coverage results
6
Embedded Systems Software Training Center Action Items Copyright © 2012 DSR Corporations
7
Action Items Copyright © 2012 DSR Corporation Foundations of Software Testing. ISTQB Certification. Dorothy Graham, Erik Van Veenendaal Prepare state diagram for BT connection, inquiry etc. Check all possible branches, return codes etc. Prepare state transition matrix for transfer protocol Design/Implement unit tests based on prepared diagram. Run unit tests. Check results. Got a code coverage. Tune tests if necessary, run 2 nd pass, check results. The final step of this technique is to write test cases to exercise each of the four rules in the table. Test cases may be enhanced with EP and BVA approaches. 7
8
Embedded Systems Software Training Center Unit tests implementation technique Copyright © 2012 DSR Corporations
9
Unit tests implementation Copyright © 2012 DSR Corporation Foundations of Software Testing. ISTQB Certification. Dorothy Graham, Erik Van Veenendaal 9 #define unit_test_1 /* enter Pin */ /* could be move to header */ //#define unit_test_2 //#define unit_test_3 ….. #Ifndef unit_test_1 int get_pin_num() {…} #else int get_pin_num(){return (int)3;} #endif
10
Embedded Systems Software Training Center Code coverage analysis Copyright © 2012 DSR Corporations
11
Code coverage example Copyright © 2012 DSR Corporation Foundations of Software Testing. ISTQB Certification. Dorothy Graham, Erik Van Veenendaal 11 void Drinker::Drink (bool beer, bool whiskey) { if (beer) { this->m_result = 1; /* Covered by Test ():1 */ } else { this->m_result = -1; /* Covered by Test ():2 */ } if (whiskey) { this->m_result = 2; /* Covered by Test ():1 */ } else { this->m_result = -2; /* Covered by Test ():2 */ } void Test() /* C0 (line coverage) is 100%, C1(branch coverage) is 100%, C2 (path coverage) is 50%. { Drinker dude = new Drinker(); dude.Drink(true, true); Assert::AreEqual(m_result, 1); dude.Drink(true, true); Assert::AreEqual(m_result, 2); }
12
Embedded Systems Software Training Center Thank you Copyright © 2012 DSR Corporations
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.