dev.bg - angular 1 and jasmine (unit testing and tdd)

51
Angular and Jasmine

Upload: dimitar-danailov

Post on 13-Apr-2017

113 views

Category:

Software


2 download

TRANSCRIPT

Page 1: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Angularand

Jasmine

Page 3: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Topics Today

● What is TDD and Unit Testing● What is Jasmine● Horrible Mistakes (Possible Mistakes)● Examples

Page 4: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
Page 5: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Priorities and Management

Page 6: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Code Base: Monolithic Applications

Page 7: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
Page 8: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Image Source: memegenerator.net

Page 9: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Team Size

Page 10: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Challenges

Page 11: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Team Size

Page 12: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Long time

Page 13: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

TDDand

Unit Testing

Page 14: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
Page 16: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Unit Testing

● Only on memory● Fast● Repeatable● Not touch any external resources

Page 17: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Class Voice Recognition

function Record(object) // void function

Voice Recognition API

Page 18: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Class Voice Recognition

function Record(object) // void function

Voice Recognition API

Fake Voice Recognition API - Mockup Object (Assert)

Page 19: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Mock objects vs Stub objects

function Record(object) // void function

Voice Recognition API

LogWritter

Page 20: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Mock objects vs Stub objects

function Record(object) // void function

Voice Recognition API

LogWritter

Page 21: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Mock objects vs Stub objects

function Record(object) // void function

Voice Recognition API

LogWritter

Fake Voice Recognition API

Fake LogWritter

Page 22: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Mock objects vs Stub objects

function Record(object) // void function

Voice Recognition API

LogWritter

Fake Voice Recognition API - Stub

Fake LogWritter - Mockup Object

(Assert)

Page 24: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
Page 25: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Possible Horrible Mistakes

Page 27: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

GOTO 2013 • JS Unit Testing Good Practices & Horrible Mistakes • Roy Osherove

Page 30: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Just by doing it,Unit Testing Makes

Your file easier

PossibleHorrible Mistake

Page 31: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Unit testing makes your developer lives easier● Easier to find bugs● Easier to maintain● Easier to understand● Easier to Developer

Unit test have bugsNo TrustRefactoringTest Code is not an important

Page 32: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

No Test Review

PossibleHorrible Mistake

Page 33: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Test reviews vs code reviews

● Understand intent of developer● 10 times quicker● Drill in when needed● Important for learning teams

Page 34: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Test reviews

● Making your test TRUSTworthy● Creating MAINTAINable tests● READable tests

RTFM

Page 35: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Mocking all the things

PossibleHorrible Mistake

Faking

Page 36: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Mock objects vs Stub objects

function Record(object) // void function

Voice Recognition API

LogWritter

Fake Voice Recognition API - Stub

Fake LogWritter - Mockup Object

(Assert)

Page 37: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Mixing Unit And Integration Tests

PossibleHorrible Mistake

Page 38: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Unit Testing

● Only on memory● Fast● Repeatable● Not touch any external resources

Page 41: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
Page 45: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
Page 46: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Лекцията на Aлекс Тодоров: Мутанти, зомбита и тестове

Page 48: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

25 % Discount - Valid for first ten registrations (FriendOfMitko)

Page 49: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
Page 50: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Resourceshttp://bit.ly/angular-jasmine

Page 51: DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)

Questions