test code by resolving method call and
play

Test Code by Resolving Method Call and Field Dependency Presented by - PowerPoint PPT Presentation

5th International Workshop on Quantitative Approaches to Software Quality Automatically Identifying Dead Fields in Test Code by Resolving Method Call and Field Dependency Presented by Abdus Satter Institute of Information Technology University


  1. 5th International Workshop on Quantitative Approaches to Software Quality Automatically Identifying Dead Fields in Test Code by Resolving Method Call and Field Dependency Presented by Abdus Satter Institute of Information Technology University of Dhaka, Dhaka 1000, Bangladesh

  2. Outline  Broad Domain – Test Smell, Dead Field  Problem Specification  Literature Review  Research Question  Proposed Technique  Result Analysis  Conclusion 2 Automatic Identification of Dead Field Dec 4, 2017

  3. Test Smell String conStr = “ +++++ ” ; DBContext dbContext = new File sampleDataFile; DBContext(); testLogin(){ void login(String userName, String for each(String line: password){ sampleDataFile.readLines()){ bool found = splitStr=line.split( ‘ ’ ); dbContext.exists(userName, assertEqual(login(splitStr[0],s password); plitStr[1],splitStr[2])); if(found == true) } session.set( “logged _ in” ); } } Production Code Test Code 3 Automatic Identification of Dead Field Dec 4, 2017

  4. Test Smell Unused Code External Resource String conStr = “ +++++ ” ; DBContext dbContext = new File sampleDataFile; DBContext(); Assume that testLogin(){ for each(String line: Data exist in void login(String userName, String sampleDataFile.readLines()){ Database password){ splitStr=line.split( ‘ ’ ); bool found = assertEqual(login(splitStr[0],s dbContext.exists(userName, plitStr[1]),splitStr[2]); password); assertEqual(logout(splitStr[0] Poor Explanation if(found == true) ), true); of Assertion session.set( “logged _ in” ); } Testing Multiple ) } Methods } 4 Automatic Identification of Dead Field Dec 4, 2017

  5. Dead Field Production Code 5 Automatic Identification of Dead Field Dec 4, 2017

  6. Dead Field Production Code Setup Method 6 Automatic Identification of Dead Field Dec 4, 2017

  7. Dead Field Production Code Setup Fields: Setup Method account facebookAccount googleAccount 7 Automatic Identification of Dead Field Dec 4, 2017

  8. Dead Field Production Code Setup Fields: Used Field: account Setup Method account facebookAccount googleAccount 8 Automatic Identification of Dead Field Dec 4, 2017

  9. Dead Field Production Code Setup Fields: Used Field: account Setup Method Dead Fields: account facebookAccount facebookAccount googleAccount googleAccount 9 Automatic Identification of Dead Field Dec 4, 2017

  10. Impact of Dead Field  Increase line of code  Decrease maintainability  Make the code difficult to comprehend  Increase the amount of production code in Test Driven Development (TDD) approach 10 Automatic Identification of Dead Field Dec 4, 2017

  11. Refactoring: improving the design of existing code[1]  Martin Fowler first introduced code smell  Discussed impact of code smells in software maintainability  Provided refactoring mechanism to remove code smells 11 Automatic Identification of Dead Field Dec 4, 2017

  12. Refactoring Test Code[2]  van Deursen first introduced term test smell  Identified eleven test smells based on the concept of code smell  Proposed different techniques to remove test smells from test code  However, no technique was provided to detect dead field because this smell was not discovered at that time 12 Automatic Identification of Dead Field Dec 4, 2017

  13. An Empirical Analysis of the Distribution of Unit Test Smells[3]  Two studies were carried out by Bavota et al. on 18 software systems with twenty masters students  Explained the distribution of test smells in test code  Described the impact of test smells in test code comprehension in the controlled experiment  However, they did not provide any information regarding dead field 13 Automatic Identification of Dead Field Dec 4, 2017

  14. Testq: Exploring structural and maintenance characteristics of unit test suites[4]  Tool presented by Bart Van Rompaey for exploring structural maintenance characteristics of test code  Eleven different test smells like assertionless, eager test and so on could be identified by the tool  Uses test smell characteristics for test smell detection  Visualization feature helps to explore test suites visually  The tool could not identify dead field as no metric was defined for the detection 14 Automatic Identification of Dead Field Dec 4, 2017

  15. Rule-based assessment of test quality[5]  This rule based tool proposed by Stefan Reichart for assessing test code quality  The tool parses the source code, analyzes the source tree, detects pattern and identifies smell  Pattern detection involved test smell characteristics  The tool could not detect dead fields as no rule was provided for it 15 Automatic Identification of Dead Field Dec 4, 2017

  16. Automated Detection of Test Fixture Strategies and Smells[6]  Introduced five new test smells  T est Maverick  Dead Fields  Lack of Cohesion of T est Methods  Obscure In-Line Setup  Vague Header setup  Implemented a tool named TestHound to detect these smells  Could identify test smells well but could not identify dead field correctly due to not considering field dependency and usage of setup fields properly 16 Automatic Identification of Dead Field Dec 4, 2017

  17. Research Question  How to develop a process to identify dead fields automatically by analyzing method call and field dependency in test methods? 17 Automatic Identification of Dead Field Dec 4, 2017

  18. Dead Field Detector (DFD)  The technique comprises four steps –  Call Graph Generation  Data Dependency Graph Generation  Setup Field Detection  Dead Field Detection 18 Automatic Identification of Dead Field Dec 4, 2017

  19. Dead Field Detector (DFD) import java.lib2 import java.lib3 int p=200; int x=p-3; int y=20; int z; int setup(int a, int b){ a=lib2.pow(a,4); x=x+a+b; return m2(x); } int m 2 (int a){ return m3()-2*a; } int m 3 (){ return y*y-2*y; } int m 4 (){ return p+x-y; 19 Automatic Identification of Dead Field Dec 4, 2017 }

  20. Dead Field Detector (DFD) import java.lib2 int setup(int a, int b){ Parsing Methods import java.lib3 a=lib2.pow(a,4); int p=200; x=x+a+b; int x=p-3; return m2(x); int y=20; int z; } int setup(int a, int b){ a=lib2.pow(a,4); int m 2 (int a){ x=x+a+b; return m3()-2*a; return m2(x); } } int m 2 (int a){ int m 3 (){ return m3()-2*a; return y*y-2*y; } } int m 3 (){ return y*y-2*y; int m 4 (){ } return p+x-y; int m 4 (){ } return p+x-y; } 20 Automatic Identification of Dead Field Dec 4, 2017

  21. Dead Field Detector (DFD) Call Graph Generation int setup(int a, int b){ a=lib2.pow(a,4); x=x+a+b; return m2(x); } setup 21 Automatic Identification of Dead Field Dec 4, 2017

  22. Dead Field Detector (DFD) Call Graph Generation int setup(int a, int b){ a=lib2.pow(a,4); x=x+a+b; return m2(x); } setup int m 2 (int a){ return m3()-2*a; } m 2 22 Automatic Identification of Dead Field Dec 4, 2017

  23. Dead Field Detector (DFD) Call Graph Generation int setup (int a, int b){ a=lib2.pow(a,4); x=x+a+b; return m2(x); } setup int m 2 (int a){ return m3()-2*a; } m 2 int m 3 (){ return y*y-2*y; } m 3 23 Automatic Identification of Dead Field Dec 4, 2017

  24. Dead Field Detector (DFD) Call Graph Generation int setup (int a, int b){ a=lib2.pow(a,4); x=x+a+b; return m2(x); } setup int m 2 (int a){ return m3()-2*a; } m 2 m 4 int m 3 (){ return y*y-2*y; } m 3 int m 4 (){ return p+x-y; } 24 Automatic Identification of Dead Field Dec 4, 2017

  25. Dead Field Detector (DFD) Call Graph Generation int setup (int a, int b){ a=lib2.pow(a,4); x=x+a+b; return m2(x); setup } int m 2 (int a){ return m3()-2*a; m 2 m 4 } int m 3 (){ return y*y-2*y; } m 3 int m 4 (){ return p+x-y; } 25 Automatic Identification of Dead Field Dec 4, 2017

  26. Dead Field Detector (DFD) Call Graph Generation int setup (int a, int b){ a=lib2.pow(a,4); x=x+a+b; return m2(x); setup } int m 2 (int a){ return m3() -2*a; m 2 m 4 } int m 3 (){ return y*y-2*y; } m 3 int m 4 (){ return p+x-y; } 26 Automatic Identification of Dead Field Dec 4, 2017

  27. Dead Field Detector (DFD) Method Call Resolution int setup (int a, int b){ a=lib2.pow(a,4); x=x+a+b; return m2(x); setup } int m 2 (int a){ return m3() -2*a; m 2 m 4 } int m 3 (){ return y*y-2*y; } m 3 int m 4 (){ return p+x-y; } 27 Automatic Identification of Dead Field Dec 4, 2017

  28. Dead Field Detector (DFD) import java.lib2 Method Call Resolution import java.lib3 int p=200; int x=p-3; int y=20; setup int z; int setup (int a, int b){ a=lib2.pow(a,4); x=x+a+b; m 2 m 4 return m2(x); } int m 2 (int a){ return m3()-2*a; m 3 } int m 3 (){ return y*y-2*y; } int m 4 (){ return p+x-y; 28 Automatic Identification of Dead Field Dec 4, 2017 }

  29. Dead Field Detector (DFD) import java.lib2 Method Call Resolution import java.lib3 int p=200; int x=p-3; int y=20; setup int z; int setup(int a, int b){ a=lib2.pow(a,4); x=x+a+b; m 2 m 4 return m2(x); } int m 2 (int a){ return m3()-2*a; m 3 } int m 3 (){ return y*y-2*y; } int m 4 (){ return p+x-y; 29 Automatic Identification of Dead Field Dec 4, 2017 }

  30. Dead Field Detector (DFD) import java.lib2 import java.lib3 int p=200; int x=p-3; int y=20; int z; int setup(int a, int b){ a=lib2.pow(a,4); x=x+a+b; return m2(x); } int m 2 (int a){ return m3()-2*a; } int m 3 (){ return y*y-2*y; } 30 Automatic Identification of Dead Field Dec 4, 2017

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend