Tdd using Jasmine and karma

12
Copyright © 2015. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential. . . TDD-Using Karma and Jasmine 1

Transcript of Tdd using Jasmine and karma

Page 1: Tdd using  Jasmine and karma

Copyright © 2015. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential...

TDD-Using Karma and Jasmine

1

Page 2: Tdd using  Jasmine and karma

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

Page 3: Tdd using  Jasmine and karma

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

Page 4: Tdd using  Jasmine and karma

www.cybage.com

4

Red Green Blue Factor

Page 5: Tdd using  Jasmine and karma

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.

Page 6: Tdd using  Jasmine and karma

www.cybage.com

How to do TDD?

6

Page 7: Tdd using  Jasmine and karma

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.

Page 8: Tdd using  Jasmine and karma

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 .

Page 9: Tdd using  Jasmine and karma

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

Page 10: Tdd using  Jasmine and karma

www.cybage.com

Code Demo

10

Page 12: Tdd using  Jasmine and karma

Copyright © 2015. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.

Thank you