js unit testingpresentation

Download Js unit testingpresentation

Post on 28-Jun-2015

31 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • 1. JavaScript Unit TestingAdoption in the Enterprisejon.gregory@microlise.com - @JonGregory77

2. Introduction Jon Gregory Technical Architect at Microlise,have been working with .Net since 2.0 Microlise supply vehicle tracking, telematicsand proof of delivery solutions. Our approach to adopting JS Unit Testing 3. Drivers Two Large Web Forms / MVC Hybrid Applications Organically grown JavaScript Unstructured large JavaScript files Increasing use of front end logic UX team using bootstrap based UI framework 4. State of JavaScript 5. State of JavaScript In-line JavaScript Difficult to read unstructured files Multiple JQuery versions JQuery selectors binding to the view Ball of wool design pattern! 6. Unit Testing 7. Unit Testing Invested heavily in C# Unit Testing Benefits in good design & confidence in code We wanted the same for JavaScript! 8. Challenges Perception it wouldn't add value Wasn't clear what could be tested We hadn't looked at what was possible Visual Studio didn't provide the tools 9. Friction FreeC# => JS 10. Real World 11. Evaluation 12. Evaluation Many tools available Community recommended top three QUnit, Jasmine and Mocha QUnit and Mocha need a mocking framework 13. Test Runner Needed to be able to run the tests! ReSharper plugin available for Mocha butrequires NodeJS Chutzpah easier and free Visual Studio plugin Chose to look at running in Node as a Phase 2 14. Approach File structure convention Mocha Controller added to MVC Applications Static HTML Training and sample applications Visual Studio / Resharper Templates 15. File Structure - MVC/Tests--/app----/ControllerName------/ViewName--------TestFileOne.Tests.js 16. File Structure - Logic/Scripts--/app----/Maths------Calculator.js/Tests--/app----/Maths------Calculator.Test.js 17. Code Demo 18. Success 19. Future 20. Future Looking at ways of adding into out continuousintegration & inspection processWork to improve JavaScript coding techniquesand writing structured JavaScriptNCrunch Style continuous runner. Continuing to promote and train to increaseuptake 21. Useful Links https://www.syncfusion.com/resources/techportal/ebooks/javascript http://www.sonarqube.org/ PluralSight Testing ClientSide JavaScript Gil Fink MSDN Jasmine Talks 22. Questions ?