Download Test-driven Development: Prioritizing Unit Test Cases for Superior Code Quality and more Study notes Computer Science in PDF only on Docsity! Data Classification Test-driven development and prioritization of test case execution Team 4 Jim Kile, Don Little, and Samir Shah 2 Topic overview What is Test-driven development (TDD)? A practice of software development that involves the implementation of a system starting from the unit test cases of an object “If you can’t write a test for what you are about to code, then you shouldn’t even be thinking about coding” Lack of upfront design Applicability of the practice for code that is difficult to test using TDD (e.g. GUIs) Reliance on refactoring to achieve code understanding and manage complexity High skill level and experience requirements Program comprehension (especially useful for maintenance activities) Efficiency through continuous feedback Creation and availability of reusable test assets Reducing defect injection during development Perceived ShortcomingsPerceived Benefits 5 The prioritization problem [5] Given T, a test suite PT, the set of permutations of T f, a function from PT to the real numbers PT represents the set of all possible prioritizations (orderings of T), and f is a function that, applied to any such ordering, yields an award value for that ordering Higher award values are preferable to lower ones This is a search problem )]()()[)()((such that Find TfTfTTPTTTPTT ′′≥′′≠′′∈′′′′∀∈′ 6 “Greedy” approach Two of the articles propose a greedy algorithm [5, 8] to solve the prioritization issue Three step process to assign execution priority Step 1: Binary match to identify (Note: This is an example of an exhaustive search ) Old blocks of code Old modified blocks of code New blocks of code Step 2: Determine whether new versions are covered by an existing test Step 3: Prioritize the order of the selected test set (greedy search) 7 “Greedy” approach (continued) Find a short sequence of tests from the given test set such that as many of the impacted blocks as possible will be covered Assigns priority weights to each test equal to the number of impacted blocks it covers The test with the maximum weight is selected and then removed from the set and each case’s weight is re-calculated Algorithm [8]: while (any t in TestList covers any block in ImpactedBlkSet) { CurrBlkSet = ImpactedBlkSet Start a new sequence Seq while (any t in TestList covers any block in CurrBlkSet } { for each t in TestList compute { Weight(t) = count[CurrBlkSet ∩ Coverage(t)] } Select test t in TestList with maximum weight Add t to current sequence Seq Remove t from TestList CurrBlkSet = CurrBlkSet – Coverage (p) } } Put all remaining tests in TestList in a new sequence Seq