Dot Net Notts Js Unit Testing at Microlise
-
Upload
jonathan-gregory -
Category
Technology
-
view
158 -
download
0
Transcript of Dot Net Notts Js Unit Testing at Microlise
Introduction
• Jon Gregory Technical Architect at Microlise, have been working with .Net since 2.0
• Microlise supply vehicle tracking, telematics and proof of delivery solutions.
• Our approach to adopting JS Unit Testing
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
State of JavaScript
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!
Unit Testing
Unit Testing
• Invested heavily in C# Unit Testing
• Benefits in good design & confidence in code
• We wanted the same for JavaScript!
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
C# => JS
Friction Free
Real World
Evaluation
Evaluation
• Many tools available
• Community recommended top three
• QUnit, Jasmine and Mocha
• QUnit and Mocha need a mocking framework
Test Runner
• Needed to be able to run the tests!
• ReSharper plugin available for Mocha but requires NodeJS
• Chutzpah easier and free Visual Studio plugin
• Chose to look at running in Node as a Phase 2
Approach
• File structure convention
• Mocha Controller added to MVC Applications
• Static HTML
• Training and sample applications
• Visual Studio / Resharper Templates
File Structure - MVC
/Tests--/app----/ControllerName------/ViewName--------TestFileOne.Tests.js
File Structure - Logic
/Scripts--/app----/Maths------Calculator.js
/Tests--/app----/Maths------Calculator.Test.js
Code Demo
Future
Future● Looking at ways of adding into out continuous integration & inspection process
● Work to improve JavaScript coding techniques and writing structured JavaScript
● NCrunch Style continuous runner.
● Continuing to promote and train to increase uptake
Useful Links● https://www.syncfusion.com/resources/techportal/ebooks/javascript
● http://www.sonarqube.org/
● PluralSight – Testing ClientSide JavaScript
● Gil Fink – MSDN – Jasmine Talks
Questions ?