Tdd using Jasmine and karma
-
Upload
siddharth-mishra -
Category
Technology
-
view
60 -
download
0
Transcript of Tdd using Jasmine and karma
Copyright © 2015. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential...
TDD-Using Karma and Jasmine
1
www.cybage.com
Copyright © 2015. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential..
Agenda
• What is TDD?
• Why ?
• How to do TDD?
• Code Demo
2
www.cybage.com
What is TDD?
3
automated tools.1-verifying that your code does what it
is expected to do with automated tools.
1-verifying that your code does what it is expected to do with automated tools
• Verifying that your code does what it is expected to do, with automated tools.
• TDD is software development process that encourages writing failing automated test case then produce the minimum amount of code required to pass that test and optionally followed by refactoring code.
• TDD helps design our code, it helps in documentation of code as well
www.cybage.com
4
Red Green Blue Factor
www.cybage.com
Why ?
5
• Enhances the code maintainability for further changes in code base as well as test case.
• Provides immediate feedback for any change in code .
• Test coverage score is high in case of test First.
• Provides the facility of breaking the negative feedback of increased defects.
www.cybage.com
How to do TDD?
6
www.cybage.com
Tools required
7
• karma/protractor –java script test runner that integrates with a number of browsers.
• jasmine version(provides better documentation ): 2.0 or qunit and sin on.
www.cybage.com
Jasmine
8
• It have Suits and Specs
• Pre Defined Matchers –toBe,toBeDefined ,toBeFalsy
• SetUp-In beforeEach prerequisites can be defined, afterEach and it also used .
www.cybage.com
9
• Number of facilities like spyOn which Jasmine has test double functions called spies
• A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it)
• Dependency Injections , Services like $timeout ,$window,$location
• Async Suport –Use WaitsFor and runs
www.cybage.com
Code Demo
10
www.cybage.com
Some References
11
• http://www.slideshare.net/cebartling/javascript-tdd-with-jasmine-and-karma
• https://blog.logentries.com/2015/01/unit-testing-with-karma-and-jasmine-for-angularjs/
• http://jsfiddle.net/B72tr
Copyright © 2015. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Thank you