automatic generation of oracles for exceptional behaviors
play

Automatic Generation of Oracles for Exceptional Behaviors a c f - PowerPoint PPT Presentation

Automatic Generation of Oracles for Exceptional Behaviors a c f i t t r A * o m C p * l e t n t e A e * t s * E i W s n e C o A l l C D T * o * S c e u s S u m E e e I R n * o t e v t


  1. Automatic Generation of Oracles for Exceptional Behaviors a c f i t t r A * o m C p * l e t n t e A e * t s * E i W s n e C o A l l C D T * o * S c e u s S u m E e e I R n * o t e v t d y s a * E a d l e u t a Alberto Go ffi — alberto.go ffi @usi.ch 
 USI Università della Svizzera italiana (Lugano, Switzerland) Alessandra Gorla 
 IMDEA Software Institute (Madrid, Spain) Michael D. Ernst 
 University of Washington (Seattle, Washington, USA) Mauro Pezzè 
 USI Università della Svizzera italiana (Lugano, Switzerland)

  2. The Oracle Problem Automatically generated test cases need oracles Formal specifications are often missing Developers write Javadoc comments Automatically generate oracles 
 from Javadoc comments

  3. The Oracle Problem Automatically generated test cases need oracles Developers do not write formal specifications Developers write Javadoc comments Automatically generate oracles 
 from Javadoc comments

  4. The Oracle Problem Automatically generated test cases need oracles Developers do not write formal specifications Developers do write Javadoc comments Automatically generate oracles 
 from Javadoc comments

  5. The Oracle Problem Automatically generated test cases need oracles Developers do not write formal specifications Developers do write Javadoc comments Automatically generate oracles 
 from Javadoc comments

  6. Testers under-test exceptions % covered statements % covered throw statements 100 80 60 40 20 0 cli collections compress dbcp email io lang math net pool primitives guava average

  7. Testers under-test exceptions % covered statements % covered throw statements 100 80 60 40 20 0 cli collections compress dbcp email io lang math net pool primitives guava average

  8. Testers under-test exceptions % covered statements % covered throw statements 100 80 60 40 20 0 cli collections compress dbcp email io lang math net pool primitives guava average

  9. Testers under-test exceptions % covered statements % covered throw statements 100 -25% 80 60 40 20 0 cli collections compress dbcp email io lang math net pool primitives guava average

  10. …and automatic testing does not help public class FilterIterator implements Iterator { public FilterIterator(Iterator i, Predicate p) {…} public Object next() {…} … }

  11. …and automatic testing does not help public class FilterIterator implements Iterator { public FilterIterator(Iterator i, Predicate p) {…} public Object next() {…} … } public void test { FilterIterator i = new FilterIterator( null , null ); i.next(); }

  12. What does an exception mean? public class FilterIterator implements Iterator { public FilterIterator(Iterator i, Predicate p) {…} public Object next() {…} … } public void test { FilterIterator i = new FilterIterator( null , null ); i.next(); } NullPointerException

  13. What does an exception mean? public class FilterIterator implements Iterator { public FilterIterator(Iterator i, Predicate p) {…} public Object next() {…} … } public void test { FilterIterator i = new FilterIterator( null , null ); i.next(); } ? 1. Expected behavior NullPointerException 2. Illegal input 3. Implementation bug

  14. What does an exception mean? public class FilterIterator implements Iterator { public FilterIterator(Iterator i, Predicate p) {…} /** * @throws NullPointerException if either * the iterator or predicate are null */ public Object next() {…} } public void test { FilterIterator i = new FilterIterator( null , null ); i.next(); } ? 1. Expected behavior NullPointerException 2. Illegal input 3. Implementation bug

  15. What does an exception mean? public class FilterIterator implements Iterator { public FilterIterator(Iterator i, Predicate p) {…} /** * @throws NullPointerException if either * the iterator or predicate are null */ public Object next() {…} } public void test { FilterIterator i = new FilterIterator( null , null ); i.next(); } 1. Expected behavior NullPointerException 2. Illegal input 3. Implementation bug

  16. What does an exception mean? public class FilterIterator implements Iterator { public FilterIterator(Iterator i, Predicate p) {…} /** * @throws NullPointerException if either * the iterator or predicate are null */ public Object next() {…} } F a l s public void test { e A FilterIterator i = new FilterIterator( null , null ); l a i.next(); r m } 1. Expected behavior NullPointerException 2. Illegal input 3. Implementation bug

  17. Consider another implementation public class FilterIterator implements Iterator { public FilterIterator(Iterator i, Predicate p) {…} /** * @throws NullPointerException if either * the iterator or predicate are null */ public Object next() {…} } public void test { FilterIterator i = new FilterIterator( null , null ); i.next(); } 3. Implementation bug ? 1. Expected behavior No Exceptions 2. Illegal input

  18. Consider another implementation public class FilterIterator implements Iterator { public FilterIterator(Iterator i, Predicate p) {…} /** * @throws NullPointerException if either * the iterator or predicate are null */ public Object next() {…} } public void test { FilterIterator i = new FilterIterator( null , null ); i.next(); } 1. Expected behavior No Exceptions 2. Illegal input 3. Implementation bug

  19. Consider another implementation public class FilterIterator implements Iterator { public FilterIterator(Iterator i, Predicate p) {…} /** * @throws NullPointerException if either * the iterator or predicate are null */ public Object next() {…} } M i s s e public void test { d FilterIterator i = new FilterIterator( null , null ); A l i.next(); a r } m 1. Expected behavior No Exceptions 2. Illegal input 3. Implementation bug

  20. public void test { FilterIterator i = Test new FilterIterator( null , null ); i.next(); }

  21. public void test { FilterIterator i = Test new FilterIterator( null , null ); i.next(); } /** * @throws NullPointerException if either Documentation * the iterator or predicate are null */ public Object next() {…}

  22. public void test { FilterIterator i = Test new FilterIterator( null , null ); i.next(); + } /** * @throws NullPointerException if either Documentation * the iterator or predicate are null */ public Object next() {…}

  23. public void test { FilterIterator i = Test new FilterIterator( null , null ); i.next(); + } /** * @throws NullPointerException if either Documentation * the iterator or predicate are null */ public Object next() {…} public void test { FilterIterator i = new FilterIterator( null , null ); if (i.getIterator() == null || i.getPredicate() == null ) { try { i.next(); Test + Oracle fail(“Expected NPE not thrown”); } catch (NullPointerException e) { // Expected exception } } else { i.next(); } }

  24. public void test { FilterIterator i = Test new FilterIterator( null , null ); i.next(); + } /** * @throws NullPointerException if either Documentation * the iterator or predicate are null */ public Object next() {…} public void test { FilterIterator i = new FilterIterator( null , null ); if (i.getIterator() == null || i.getPredicate() == null ) { try { i.next(); Test + Oracle fail(“Expected NPE not thrown”); } catch (NullPointerException e) { // Expected exception } } else { i.next(); } }

  25. public void test { FilterIterator i = Test new FilterIterator( null , null ); i.next(); + } /** * @throws NullPointerException if either Documentation * the iterator or predicate are null */ public Object next() {…} public void test { FilterIterator i = new FilterIterator( null , null ); if (i.getIterator() == null || i.getPredicate() == null ) { try { i.next(); Test + Oracle fail(“Expected NPE not thrown”); } catch (NullPointerException e) { // Expected exception } } else { i.next(); } }

  26. Toradocu Javadoc 
 Condition 
 Oracle 
 Enhanced Source Extractor Translator Generator Tests Tests

  27. Javadoc 
 Condition 
 Oracle 
 Enhanced Source Extractor Translator Generator Tests

  28. Javadoc 
 Condition 
 Oracle 
 Enhanced Source Extractor Translator Generator Tests 1. Method Signature 2. Expected Exceptions Source 3. Conditions (Text)

  29. Javadoc 
 Condition 
 Oracle 
 Enhanced Source Extractor Translator Generator Tests 1. Method Signature 2. Expected Exceptions Source 3. Conditions (Text) /** 1. FilterIterator.next() * @throws NullPointerException 2. NullPointerException * if either the iterator * or predicate are null 3. “if either the iterator 
 */ or predicate are null” public Object next() {…}

  30. Javadoc 
 Condition 
 Oracle 
 Enhanced Source Extractor Translator Generator Tests 1. Method Signature 1. Method Signature 2. Expected Exceptions 2. Expected Exceptions 3. Conditions (Text) 3. Conditions (Code)

  31. Javadoc 
 Condition 
 Oracle 
 Enhanced Source Extractor Translator Generator Tests 1. Method Signature 1. Method Signature 2. Expected Exceptions 2. Expected Exceptions 3. Conditions (Text) 3. Conditions (Code) 1. FilterIterator.next() 1. FilterIterator.next() 2. NullPointerException 2. NullPointerException 3. “if either the iterator or 3. getIterator() == null || 
 predicate are null” getPredicate() == null

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