introduction of unit test to management

22
Introduction of Unit Test to Management and Business August, 2012 Wei Li

Upload: weiliatslideshare

Post on 13-Dec-2014

573 views

Category:

Technology


1 download

DESCRIPTION

An introduction of unit test and its benefits to business and management

TRANSCRIPT

Page 1: Introduction of unit test to management

Introduction of Unit Test to Management and Business

August, 2012

Wei Li

Page 2: Introduction of unit test to management

”To err is human;

to forgive, divine.”

Alexander Pope

Page 3: Introduction of unit test to management

Developer Test

– Unit Test

– Integration Test

– Regression Test

QA Test

– Integration Test

– Regression Test

– Performance Test

– Stress Test

Customer/User Test

– Acceptability Test

– Usability Test

Many Tests in the Life Cycle of Software Development

Page 4: Introduction of unit test to management

What is Unit Test

Self checking or validation to ensure the code work as expected

Developer’s test

Part of construction cycle

Foundation of all other tests

Page 5: Introduction of unit test to management

Where Does Unit Test Fit in Life Cycle?

Requirement gathering

Business Design

Technical Design

– Architecture Design

– Technical Design

Construction

– Code and Unit Test

QA Test

Performance Test

User Test

Page 6: Introduction of unit test to management

Unit Test Is Not

QA test

Customer/user test

Page 7: Introduction of unit test to management

Why?

What? Write code to test code?

No! I don’t have time for it!

Page 8: Introduction of unit test to management

Benefits of Unit Test – Instant Feedback

Unit test provides the earliest opportunity to identify and fix a defect

The earlier an error is found, the less expensive it is to fix it

Performed before components are integrated together

Page 9: Introduction of unit test to management

Force the developer to write clean and testable code – which leads to less complexity and better design

If your code is hard to be tested, how can it be easily used, maintained and extended?

Benefits of Unit Test – Write Testable Code

Page 10: Introduction of unit test to management

Benefits of Unit Test – Establish Safety Net in the Lifecycle

Can be used as part of regression test suite

Provide the green light to refactor old code and make changes

Page 11: Introduction of unit test to management

Benefits of Unit Test – Good Way to Work with Legacy/Existing Code

Write unit test to get started understanding legacy code and system

Page 12: Introduction of unit test to management

Benefits of Unit Test – Excellent Way to Learn New Language and API

Write unit test cases to learn and try new API

The unit test cases can become reusable knowledge base

Page 13: Introduction of unit test to management

Benefits of Unit Test – Excellent Way to Report a Defect

Write a unit test case to report a defect or a bug in the system

Run the same test to verify the defect is fixed

Page 14: Introduction of unit test to management

Benefits of Unit Test - Reusability

Write once run forever – reusable and repeatable

Save time long term in the life cycle

Give new team member a good jump start

Page 15: Introduction of unit test to management

Unit Test Practice

Planning and estimation - account for the construction time for unit test

Code a little and unit test a little - repeat the cycle until the construction is done

Part of the code review process

Run unit test when trouble shooting issues

Run unit test whenever a change is made

Run unit test whenever is needed

Enjoy the results

Page 16: Introduction of unit test to management

Our old friend JUnit is still our best friend

– No new wheel was reinvented

– De facto tool

– Familiarity to most developers

Unit Test Practice

Page 17: Introduction of unit test to management

Use a separate unit test project

– Only contain unit test related Java code but test code in other projects

– Run locally and not deployed to application server

Won’t be part of the deployable to application server

– Freedom to write more unit tests

– Save time in testing (no build and deployment)

Unit Test Practice

Page 18: Introduction of unit test to management

Unit test coverage – the thorough the better

Unit Test Practice

Page 19: Introduction of unit test to management

Just do it and it will become a habit

You will find out you actually have time to write unit test code

You will find out you actually enjoy doing it

Unit Test Practice

Page 20: Introduction of unit test to management

Test Driven/Test First Methodology

Write a test case for a new functionality

Run the test and it fails

Write just enough code to make the test pass

Run the test and it passes

Refactor the code to make it better

Repeat the test

Repeat the cycle

Page 21: Introduction of unit test to management

Continuous Integration

Get the latest version of the code from source control system

Build/compile the code

Run all unit test cases

Publish the build and test results

Notify the development team for any failure

Repeat the process periodically, for example, once every hour

Page 22: Introduction of unit test to management

”To err is developer;

to catch early, unit test.”