test driven development

9
Test Driven Development Dr. Davut Çulha

Upload: dcsunu

Post on 16-Apr-2017

825 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Test Driven Development

Test Driven Development

Dr. Davut Çulha

Page 2: Test Driven Development

Test-driven Development (TDD)

• Test-driven development (TDD) is a software development process that employs very short development cycle:

– Testing

– Coding

– Refactoring

• TDD = Test-first Programming + Refactoring.

– Test-first programming is used in XP.

Page 3: Test Driven Development

Test-driven Development (TDD)

• TDD substantially reduces the incidence of defects.

• It helps to improve the design of coding.

• It minimizes the usage of debuggers.

Page 4: Test Driven Development

Write Test Code

• At each cycle of TDD, each new feature begins with writing a test.

• If the feature is not very small, only a very small part of it is taken as a feature. This rule is applied for the rest of the initial feature.

• After writing the test, execute it. It will fail. If it does not fail, repeat the process until failure.

• Test codes should not be dependent to each other.

Page 5: Test Driven Development

Write Some Code

• Before coding actual feature, you should have taken the failure for the test.

• Write some code which is just enough to pass the test. In other words, the failure will not be taken.

Page 6: Test Driven Development

Refactor

• Remove duplications.

• Improve your code quality.

• Use good naming.

• Increase readibility.

• Modularize the codes.

• Use design patterns.

• Do not change the external behaviour of the code. Change only the internal behaviour of the code to get technical excellence.

Page 7: Test Driven Development

Reversible Changes

• If the new feature addition takes a complex error, go to the last stable state.

• Implement the same feature from the beginning.

• Instead of using debugging and solving the problem, use reversible changes property of TDD.

• Every change should be reversible. Start from the last stable state.

Page 8: Test Driven Development

Documentation

• Every test code is a kind of documentation.

• It describes the interface of the actual coding.

• Every test code is a sample program to investigate the actual program.

Page 9: Test Driven Development

Code Base

• In addition to actual codes, there are test codes.

• The test codes should also be managed carefully.

• The test codes should be kept as simple as you can like the actual codes.