dom transactions for testing javascript
play

DOM Transactions for Testing JavaScript Phillip Heidegger, Annette - PowerPoint PPT Presentation

Introduction JavaScript Unit Tests of Contracts Implementation Conclusion DOM Transactions for Testing JavaScript Phillip Heidegger, Annette Bieniusa, Peter Thiemann University of Freiburg 2010/09/05 Introduction JavaScript Unit Tests


  1. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion DOM Transactions for Testing JavaScript Phillip Heidegger, Annette Bieniusa, Peter Thiemann University of Freiburg 2010/09/05

  2. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Setting: Whitebox Unit Testing of JavaScript Code 1 / ∗∗ object → bool ∗ / 2 function h(x) { if ((x) && (x.longpropertyname)) 3 return ”false” ; 4 return true; 5 6 } ;

  3. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Setting: Whitebox Unit Testing of JavaScript Code 1 / ∗∗ object → bool ∗ / 2 function h(x) { if ((x) && (x.longpropertyname)) 3 return ”false” ; 4 return true; 5 6 } ; • Find counter example for contracts • Finding bugs in JavaScript programs • Understanding JavaScript programs

  4. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion JavaScript – Features Some important features: • Weak, dynamic typing • Object-based language (no classes, but prototypes) • Functions are first class values • Side effects

  5. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Checking Contracts of pure Functions • Monitoring of contracts (assertions) • Unit Testing with random generated data • Generate random data for parameters • check return contract • Isolated test cases

  6. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Checking Contracts of pure Functions • Monitoring of contracts (assertions) • Unit Testing with random generated data • Generate random data for parameters • check return contract • Isolated test cases Side Effects ? �

  7. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Side effects? Why not include side effects in the contracts? • Programmers typically introduces contracts incremental • Contracts do not specify the complete behavior of the system Default is: • Everything that is not forbidden, is allowed

  8. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Handling Side Effects 1. Contracts with a setup and teardown function • Means a lot of work 2. Restart browser after each test run • Takes seconds 3. ?

  9. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Handling Side Effects Transactions on HTML pages

  10. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Transactions Body of our test loop: • Begin a transaction • Generate test data • Run unit under test • Check contract • Revert changes

  11. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Implementation • Integrated into JSConTest • Contracts for Specification • Random Testing • Guided Random Testing • Log based transactions • Transformation of code under test • Browser independent

  12. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Implementation • Integrated into JSConTest • Contracts for Specification • Random Testing • Guided Random Testing • Log based transactions • Transformation of code under test • Browser independent We can not revert every side effect, but − → setup / teardown or browser restart is rarely necessary

  13. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Performance? Slowdown: ≈ 4 . 3

  14. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Performance? Slowdown: ≈ 4 . 3 But we get: • Contract monitoring • Transaction system • Random data generation − → much better then restart the browser

  15. Introduction JavaScript Unit Tests of Contracts Implementation Conclusion Conclusion JSConTest • Contract testing framework for JS • Transactions for functions with side effects • Browser independent • http://proglang.informatik. uni-freiburg.de/JSConTest/

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