searching for the best tests
play

Searching for the Best Tests An Introduction to Automated Software - PowerPoint PPT Presentation

Searching for the Best Tests An Introduction to Automated Software Testing with Search-Based Techniques Gregory M. Kapfhammer Department of Computer Science Allegheny College March 31, 2015 Software is Everywhere Software is


  1. What is a Test Suite? A test suite is an organized collection of test cases T 1

  2. What is a Test Suite? A test suite is an organized collection of test cases T 1 T 2

  3. What is a Test Suite? A test suite is an organized collection of test cases T 1 T 2 T 3

  4. What is a Test Suite? A test suite is an organized collection of test cases T 1 T 2 T 3 T 4

  5. What is a Test Suite? A test suite is an organized collection of test cases T 1 T 2 T 3 T 4 . . .

  6. What is a Test Suite? A test suite is an organized collection of test cases T 1 T 2 T 3 T 4 T n . . .

  7. What is a Test Suite? A test suite is an organized collection of test cases Organize the Test Cases into a Test Suite T 1 T 2 T 3 T 4 T n . . .

  8. What is a Test Suite? A test suite is an organized collection of test cases Organize the Test Cases into a Test Suite T 1 T 2 T 3 T 4 T n . . . Tool Support for Software Testing?

  9. What is a Test Suite? A test suite is an organized collection of test cases Organize the Test Cases into a Test Suite T 1 T 2 T 3 T 4 T n . . . Tool Support for Software Testing? JUnit

  10. What is a Test Suite? A test suite is an organized collection of test cases Organize the Test Cases into a Test Suite T 1 T 2 T 3 T 4 T n . . . Tool Support for Software Testing? Apache Ant JUnit

  11. What is a Test Suite? A test suite is an organized collection of test cases Organize the Test Cases into a Test Suite T 1 T 2 T 3 T 4 T n . . . Tool Support for Software Testing? Apache Ant Eclipse JUnit

  12. A JUnit Test Case @Test public void testOne() { String expected = new String("Undefined"); String actual = Kinetic. computeVelocity(5,0); assertEquals(expected, actual); }

  13. Another JUnit Test @Test public void testTwo() { String expected = new String("0"); String actual = Kinetic. computeVelocity(0,5); assertEquals(expected, actual); }

  14. Important Questions Not all tests have the same fault detection effectiveness! Will these test cases find the fault in the example program?

  15. Important Questions Not all tests have the same fault detection effectiveness! T 1 assigns K = 5 , m = 0 — Pass or fail?

  16. Important Questions Not all tests have the same fault detection effectiveness! T 2 assigns K = 0 , m = 5 — Pass or fail?

  17. Important Questions Not all tests have the same fault detection effectiveness! How do we study the effectiveness of different test cases?

  18. The PIE Model There are necessary and sufficient conditions for fault detection ◮ Execute the faulty source code ◮ Infect the program’s data state ◮ Propagate to the program’s output All of these must occur before the fault manifests itself as a failure! Using PIE, will the test cases find the defect in the program?

  19. The PIE Model There are necessary and sufficient conditions for fault detection ◮ Execute the faulty source code ◮ Infect the program’s data state ◮ Propagate to the program’s output All of these must occur before the fault manifests itself as a failure! Using PIE, will the test cases find the defect in the program?

  20. The PIE Model There are necessary and sufficient conditions for fault detection ◮ Execute the faulty source code ◮ Infect the program’s data state ◮ Propagate to the program’s output All of these must occur before the fault manifests itself as a failure! Using PIE, will the test cases find the defect in the program?

  21. The PIE Model There are necessary and sufficient conditions for fault detection ◮ Execute the faulty source code ◮ Infect the program’s data state ◮ Propagate to the program’s output All of these must occur before the fault manifests itself as a failure! Using PIE, will the test cases find the defect in the program?

  22. The PIE Model There are necessary and sufficient conditions for fault detection ◮ Execute the faulty source code ◮ Infect the program’s data state ◮ Propagate to the program’s output All of these must occur before the fault manifests itself as a failure! Using PIE, will the test cases find the defect in the program?

  23. The PIE Model There are necessary and sufficient conditions for fault detection ◮ Execute the faulty source code ◮ Infect the program’s data state ◮ Propagate to the program’s output All of these must occur before the fault manifests itself as a failure! Using the PIE model, will the test cases find the defect in the program?

  24. A JUnit Test Case — T 1 @Test public void testOne() { String expected = new String("Undefined"); String actual = Kinetic. computeVelocity(5,0); assertEquals(expected, actual); } E I P ✗ ✗ ✗

  25. A JUnit Test Case — T 1 @Test public void testOne() { String expected = new String("Undefined"); String actual = Kinetic. computeVelocity(5,0); assertEquals(expected, actual); } E I P ✗ ✗ ✗

  26. A JUnit Test Case — T 2 @Test public void testTwo() { String expected = new String("0"); String actual = Kinetic. computeVelocity(0,5); assertEquals(expected, actual); } E I P ✗ ✗ ✓

  27. A JUnit Test Case — T 2 @Test public void testTwo() { String expected = new String("0"); String actual = Kinetic. computeVelocity(0,5); assertEquals(expected, actual); } E I P ✗ ✗ ✓

  28. A JUnit Test Case — T 3 @Test public void testThree() { String expected = new String("4"); String actual = Kinetic. computeVelocity(8,1); assertEquals(expected, actual); } E I P ✗ ✓ ✓

  29. A JUnit Test Case — T 3 @Test public void testThree() { String expected = new String("4"); String actual = Kinetic. computeVelocity(8,1); assertEquals(expected, actual); } E I P ✗ ✓ ✓

  30. A JUnit Test Case — T 4 @Test public void testFour() { String expected = new String("20"); String actual = Kinetic. computeVelocity(1000,5); assertEquals(expected, actual); } E I P ✗ ✓ ✓

  31. A JUnit Test Case — T 4 @Test public void testFour() { String expected = new String("20"); String actual = Kinetic. computeVelocity(1000,5); assertEquals(expected, actual); } E I P ✓ ✓ ✓

  32. Test Suite Summary A test case must create specific inputs in order to cause failure! Test Case Status Pass T 1 T 2 Pass T 3 Pass T 4 Fail

  33. Important Insights Software testing is fundamentally challenging — is there help? I shall not deny that the construction of these testing programs has been a major intellectual effort: to convince oneself that one has not overlooked “a relevant state” and to convince oneself that the testing programs generate them all is no simple matter. Edsger W. Dijkstra , Communications of the ACM, 1968

  34. The Challenges of Software Development Pervasiveness of Software Complexity of Software Evolving Nature of Software Motivating Example Important Questions Benefits of Software Testing Test Cases Test Suites Examples of Tests The PIE Model Test Case Effectiveness Search-Based Software Testing Testing Methods Random Testing Testing with EvoSuite Conclusion

  35. The Challenges of Software Development Pervasiveness of Software Complexity of Software Evolving Nature of Software Motivating Example Important Questions Benefits of Software Testing Test Cases Test Suites Examples of Tests The PIE Model Test Case Effectiveness Search-Based Software Testing Testing Methods Random Testing Testing with EvoSuite Conclusion

  36. The Challenges of Software Development Pervasiveness of Software Complexity of Software Evolving Nature of Software Motivating Example Important Questions Benefits of Software Testing Test Cases Test Suites Examples of Tests The PIE Model Test Case Effectiveness Search-Based Software Testing Testing Methods Random Testing Testing with EvoSuite Conclusion

  37. The Challenges of Software Development Pervasiveness of Software Complexity of Software Evolving Nature of Software Motivating Example Important Questions Benefits of Software Testing Test Cases Test Suites Examples of Tests The PIE Model Test Case Effectiveness Search-Based Software Testing Testing Methods Random Testing Testing with EvoSuite Conclusion

  38. Manual Testing While it has benefits, this industry standard may be limited! Manual Testing

  39. Manual Testing While it has benefits, this industry standard may be limited! Manual Testing Laborious

  40. Manual Testing While it has benefits, this industry standard may be limited! Manual Testing Laborious Time Consuming

  41. Manual Testing While it has benefits, this industry standard may be limited! Manual Testing Laborious Time Very Consuming Tedious

  42. Manual Testing While it has benefits, this industry standard may be limited! Manual Testing Laborious Difficult Time Very Consuming Tedious

  43. Manual Testing While it has benefits, this industry standard may be limited! Can we develop and employ methods that will automatically generate high- quality test cases for real-world software? Manual Testing Laborious Difficult Time Very Consuming Tedious

  44. Automated Testing Automatically generating tests is amazing — but does it work? Automated Testing

  45. Automated Testing Automatically generating tests is amazing — but does it work? Automated Testing Laborious

  46. Automated Testing Automatically generating tests is amazing — but does it work? Automated Testing Laborious Time Consuming

  47. Automated Testing Automatically generating tests is amazing — but does it work? Automated Testing Laborious Time Very Consuming Tedious

  48. Automated Testing Automatically generating tests is amazing — but does it work? Automated Testing Laborious Difficult Time Very Consuming Tedious

  49. Automated Testing Automatically generating tests is amazing — but does it work? Testing is less laborious and tedious because an algorithm generates the tests. While computational time is needed, a human can be less involved! Automated Testing Laborious Laborious Difficult Time Time Very Very Consuming Consuming Tedious Tedious

  50. Automated Testing Automatically generating tests is amazing — but does it work? Automated testing is less difficult since a good fitness function can guide the algorithm to inputs that find the faults Automated Testing Laborious Laborious Laborious Difficult Difficult Time Time Time Very Very Very Consuming Consuming Consuming Tedious Tedious Tedious

  51. Random Testing It is easy to randomly generate tests — but how good are they? 1 0 . 5 0 − 0 . 5 − 1 − 2 − 4 − 6 0 2 4 6 0 2 10 12 4 14 6 8

  52. Search-Based Testing Use a fitness function to guide the search to “good” values 1 0 . 5 1 0 0 0 . 5 0 . 2 0 . 4 0 . 6 0 . 8 1 0

  53. Mutation Testing Let’s purposefully insert faults into the program under test! T 1 T 2

  54. Mutation Testing Let’s purposefully insert faults into the program under test! T 3 T 4 T 1 T 2

  55. Mutation Testing Let’s purposefully insert faults into the program under test! T 3 T 4 T 5 T 1 T 2 T 6

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