19
AutomationTesting introduction eleks.com

#1 unit testing

Embed Size (px)

Citation preview

Page 1: #1 unit testing

AutomationTesting introduction

eleks.com

Denys Skrypnyk
Не вистачає слайду з Схемками по Темплейту Сібіковського.
Denys Skrypnyk
Зараз Саша таке малює, тому можеш глянути в неї.
Halyna Hlynska
По темплейту Сібіковського в гугл доці не вийде. Тому що нам потрібен конструктор, щоб люди самі собі складали з квадратіків/стрілочок схемки тут та одразу правили. Зараз зроблю базову витяжку з усього нами намальованого.
Page 2: #1 unit testing

Agenda

• What and why automated testing?• Types of automated testing• When, Why, What automated

testing is needed• Unit testing 101• Unit testing tools

Page 3: #1 unit testing

Why automated testing?• Testing happens to be complex

and expensive• Application tends to be very

complex to completely retest• Frequent releases• Long-term application support• Need to tell if application is

working after each commit/sprint in short term

Page 4: #1 unit testing

Types of automated testing

UnitIntegration

Performance

Load

Stress

Penetration

Functional

Many more

Page 5: #1 unit testing

When automated testing is needed?

• Good to have it always if possible

• When application requires complex setup scenarios for testing

• When testing takes long time to be performed

Page 6: #1 unit testing

When automate?

• During development collaboratively

• After development by separate team if it is even possible

Page 7: #1 unit testing

Unit testing

Page 8: #1 unit testing

Unit testing

• Smallest testable part• Method level• Isolated• Forces better design• “mock” out what your not

testing fake data access class when testing business logic

Page 9: #1 unit testing

Good unit test

• Fast• Readable• Maintainable• Reasonable• Independent• Working

Page 10: #1 unit testing

Test Driven Development

Page 11: #1 unit testing

Demo

Page 12: #1 unit testing

Unit tests naming practices

• MethodName_StateUnderTest_ExpectedBehavior

Add_TwoAndFive_ReturnsSeven• Test[feature being tested]

TestThrowExceptionIfDivideByZero

• Given_PreconditionsWhen_StateUnderTest

Then_ExpectedBehaviorGivenCalculator_When_DivideByZero_Then_ThrowDivideByZeroException

Page 13: #1 unit testing

Arrange->Act->Assert

Page 14: #1 unit testing

Black magic

Page 15: #1 unit testing

Unit testing frameworks

.NET: • xUnit and nUnit (mostly same features)

Page 16: #1 unit testing

Isolation techniques

• Dummy – no implementation• Fake/Stub – minimal

implementation• Mock – verify if being called• Spy – record what been called

Page 17: #1 unit testing

Demo

Page 18: #1 unit testing

Mocking frameworks

Free:• Moq, JustMockLiteCommercial:• TypeMock Isolator,

JustMock, Fakes

Page 19: #1 unit testing

Inspired by Technology.Driven by Value.

Find us at eleks.com

Have a question? Write to [email protected]