#1 unit testing

Post on 10-Feb-2017

1.304 views 0 download

Transcript of #1 unit testing

AutomationTesting introduction

eleks.com

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

Agenda

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

testing is needed• Unit testing 101• Unit testing tools

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

Types of automated testing

UnitIntegration

Performance

Load

Stress

Penetration

Functional

Many more

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

When automate?

• During development collaboratively

• After development by separate team if it is even possible

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

Good unit test

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

Test Driven Development

Demo

Unit tests naming practices

• MethodName_StateUnderTest_ExpectedBehavior

Add_TwoAndFive_ReturnsSeven• Test[feature being tested]

TestThrowExceptionIfDivideByZero

• Given_PreconditionsWhen_StateUnderTest

Then_ExpectedBehaviorGivenCalculator_When_DivideByZero_Then_ThrowDivideByZeroException

Arrange->Act->Assert

Black magic

Unit testing frameworks

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

Isolation techniques

• Dummy – no implementation• Fake/Stub – minimal

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

Demo

Mocking frameworks

Free:• Moq, JustMockLiteCommercial:• TypeMock Isolator,

JustMock, Fakes

Inspired by Technology.Driven by Value.

Find us at eleks.com

Have a question? Write to eleksinfo@eleks.com