test generation with jml
play

Test Generation with JML Part I JMLUnitNG Wojciech Mostowski, - PowerPoint PPT Presentation

Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Test Generation with JML Part I JMLUnitNG Wojciech Mostowski, Gabriele Paganelli http://wwwhome.ewi.utwente.nl/~mostowskiwi/


  1. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Test Generation with JML Part I – JMLUnitNG Wojciech Mostowski, Gabriele Paganelli http://wwwhome.ewi.utwente.nl/~mostowskiwi/ http://www.cse.chalmers.se/~gabpag/ University of T wente Chalmers University of Technology Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  2. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Overview Part I ◮ JML as test oracle Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  3. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Overview Part I ◮ JML as test oracle ◮ Test data generation Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  4. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Overview Part I ◮ JML as test oracle ◮ Test data generation ◮ JMLTestNG Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  5. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Overview Part I ◮ JML as test oracle ◮ Test data generation ◮ JMLTestNG ◮ Good specifications for testing Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  6. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Overview Part I ◮ JML as test oracle ◮ Test data generation ◮ JMLTestNG ◮ Good specifications for testing Part II ◮ Provide even better test data with KeY Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  7. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References The Basic Idea Use JML specs to check I/O behaviour of methods Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  8. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References The Basic Idea Use JML specs to check I/O behaviour of methods ◮ Take the input test data, evaluate the precondition ◮ if true run the method with input data ◮ if false skip – meaningless test Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  9. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References The Basic Idea Use JML specs to check I/O behaviour of methods ◮ Take the input test data, evaluate the precondition ◮ if true run the method with input data ◮ if false skip – meaningless test ◮ After the execution of the method evaluate the postcondition ◮ if true – test passed ◮ if false – test fail, quote the values of the input data Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  10. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Running Example /*@ public normal_behavior requires param >= 0; ensures \result >= 10; also public normal_behavior requires param < 0; ensures \result < -10; @*/ public int makeHole( int param) { if (param >= 0) { return param + 10; } else { return param - 10; } } Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  11. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Running Example /*@ public normal_behavior ◮ Take param==0 , first requires param >= 0; precondition true, the first ensures \result >= 10; spec defines a meaningful also public normal_behavior test requires param < 0; ensures \result < -10; @*/ public int makeHole( int param) { if (param >= 0) { return param + 10; } else { return param - 10; } } Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  12. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Running Example /*@ public normal_behavior ◮ Take param==0 , first requires param >= 0; precondition true, the first ensures \result >= 10; spec defines a meaningful also public normal_behavior test requires param < 0; ◮ The second does not, skip ensures \result < -10; further checks @*/ public int makeHole( int param) { if (param >= 0) { return param + 10; } else { return param - 10; } } Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  13. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Running Example /*@ public normal_behavior ◮ Take param==0 , first requires param >= 0; precondition true, the first ensures \result >= 10; spec defines a meaningful also public normal_behavior test requires param < 0; ◮ The second does not, skip ensures \result < -10; further checks @*/ public int makeHole( int param) { ◮ Execute method, check if (param >= 0) { the postcondition(s) return param + 10; (true), test pass } else { return param - 10; } } Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  14. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Running Example /*@ public normal_behavior ◮ Take param==0 , first requires param >= 0; precondition true, the first ensures \result >= 10; spec defines a meaningful also public normal_behavior test requires param < 0; ◮ The second does not, skip ensures \result < -10; further checks @*/ public int makeHole( int param) { ◮ Execute method, check if (param >= 0) { the postcondition(s) return param + 10; (true), test pass } else { return param - 10; ◮ Test with other inputs. . . } } Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  15. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Running Example /*@ public normal_behavior ◮ Take param==0 , first requires param >= 0; precondition true, the first ensures \result >= 10; spec defines a meaningful also public normal_behavior test requires param < 0; ◮ The second does not, skip ensures \result < -10; further checks @*/ public int makeHole( int param) { ◮ Execute method, check if (param >= 0) { the postcondition(s) return param + 10; (true), test pass } else { return param - 10; ◮ Test with other inputs. . . } ◮ What inputs?! } Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  16. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Test Data Generation ◮ Primitive types: ◮ Choose characteristic and borderline values e.g. Integer.MIN_VALUE , -1 , 0 , 1 , Integer.MAX_VALUE Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  17. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Test Data Generation ◮ Primitive types: ◮ Choose characteristic and borderline values e.g. Integer.MIN_VALUE , -1 , 0 , 1 , Integer.MAX_VALUE ◮ Provide manual input: -872463 , 123316 Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  18. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Test Data Generation ◮ Primitive types: ◮ Choose characteristic and borderline values e.g. Integer.MIN_VALUE , -1 , 0 , 1 , Integer.MAX_VALUE ◮ Provide manual input: -872463 , 123316 ◮ Still may not be enough – KeY can do better Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  19. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Test Data Generation ◮ Primitive types: ◮ Choose characteristic and borderline values e.g. Integer.MIN_VALUE , -1 , 0 , 1 , Integer.MAX_VALUE ◮ Provide manual input: -872463 , 123316 ◮ Still may not be enough – KeY can do better ◮ Reference types: ◮ Objects created with default constructors Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  20. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Test Data Generation ◮ Primitive types: ◮ Choose characteristic and borderline values e.g. Integer.MIN_VALUE , -1 , 0 , 1 , Integer.MAX_VALUE ◮ Provide manual input: -872463 , 123316 ◮ Still may not be enough – KeY can do better ◮ Reference types: ◮ Objects created with default constructors ◮ Manual object factories. . . Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  21. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Test Data Generation ◮ Primitive types: ◮ Choose characteristic and borderline values e.g. Integer.MIN_VALUE , -1 , 0 , 1 , Integer.MAX_VALUE ◮ Provide manual input: -872463 , 123316 ◮ Still may not be enough – KeY can do better ◮ Reference types: ◮ Objects created with default constructors ◮ Manual object factories. . . We are getting close to regular, laborous test case writing Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

  22. Overview Basics Test Data JMLUnitNG Demo Good Specifications Examples References Test Data Generation ◮ Primitive types: ◮ Choose characteristic and borderline values e.g. Integer.MIN_VALUE , -1 , 0 , 1 , Integer.MAX_VALUE ◮ Provide manual input: -872463 , 123316 ◮ Still may not be enough – KeY can do better ◮ Reference types: ◮ Objects created with default constructors ◮ Manual object factories. . . We are getting close to regular, laborous test case writing ◮ Use reflection to create objects with arbitrary constructors Wojciech Mostowski & Gabriele Paganelli Test Generation with JML

Recommend


More recommend