4. Why Unit Test?
• Promote better design – loose coupling
• Helps developers to write
– Testable unit
– Maintainable code
• Improves quality at unit level
5. Difficulties/Problems
• Lack of structure
• Function not exposed outside
• Complexity in the function ( > 10 lines )
• Tight coupling between components
6. Solutions from AngularJS
• Structure
– Module, Model, View, Controller, Service,
Templates, Filters
• Function not exposed outside
– Service, Factory, Constant, Value
• Complexity in the function ( > 10 lines )
– Module, Injectable Components
• Tight coupling between components
– Loose coupling with Structure, Module
7. Tools
• JS Libraries
– Jasmine, Qunit, Mocha
• Test Runner
– Chutzpah
• Visual Studio Plug-ins
– Chutzpah Test Adapter for the Test Explorer
– Chutzpah Test Runner Context Menu Extension
– Karma Test Adapter
8. Get to know Jasmine
• Supports BDD (User Story)
– Spec (describe, it)
– Nest-able Spec
• Powerful Matchers (+ Customer Matcher)
• Powerful concept like Spy
• Supported by Visual Studio
– Test Explorer (includes JS Unit Tests)
– Recognizes your changes to Unit Test
9. Get to know Chutzpah
• Test Runner
– Right Click and Run
– Runs automatically in Visual Studio when you
make changes to Unit Test
• Code Coverage
– From Visual Studio
– From Command Line
– Exclude and Include files using expression
– Context sensitive to File or Folder