11

Click here to load reader

Unit Testing Basics

Embed Size (px)

DESCRIPTION

Slides form very basic introductory talk about unit testing.

Citation preview

Page 1: Unit Testing Basics

Unit Testing Basics

Serhiy Oplakanets @ Mavenresearch, November 2010Slides are not intended to make sense outside of the talk.

Thursday, November 18, 2010

Page 2: Unit Testing Basics

A Discipline

• Unit Testing is a discipline of Quality Assurance

• Others Include:

• Functional Testing

• Integration Testing

• Code Review

• Continuous Integration

• ...

Thursday, November 18, 2010

Page 3: Unit Testing Basics

Unit Testing is

• validating that individual units of application work properly

Thursday, November 18, 2010

Page 4: Unit Testing Basics

Benefits

• Finding bugs early

• Less debugging

• Changes to application are safer and easier

• Examples of code usage

• Documentation (to some extent)

• Unit test is a tool to validate code design; in most cases code that is hard to test is badly designed

Thursday, November 18, 2010

Page 5: Unit Testing Basics

Good Unit Test

• Test only one unit at a time

• Do not depend on ordering of test run

• Runs fast

• Tests only one feature at a time

• Easy to understand

• Tests the public API of unit

• Covers all usage cases

Thursday, November 18, 2010

Page 6: Unit Testing Basics

Test Suite

• Multiple tests form Test Suite

• Your most important tool to check impact of changes

• Helps estimate changes

Thursday, November 18, 2010

Page 7: Unit Testing Basics

Good Unit Test Suite

• Is simple to run

• Runs fast (preferable in seconds)

• Is always Green

• Is non-interactive

Thursday, November 18, 2010

Page 8: Unit Testing Basics

Limitations of Unit Testing

• Not every bug can be found by unit tests

• As we're testing only one module -- integration issues are not covered

• Multi-threaded issues can't be caught by one-threaded test

• Hardware failures, 3rd party component issues, etc. All those can be covered only with a proper Functional Test Suite

Thursday, November 18, 2010

Page 9: Unit Testing Basics

Practical Session

Thursday, November 18, 2010

Page 11: Unit Testing Basics

Thank you.

Thursday, November 18, 2010