Test-driven-development
How to develop software in high quality mode
&
Who is ?
Hackerstolz is a young club from the Rhine-Neckar region. We organize
Hackathons, promote the digital culture and advocate for more women in the IT
field .
Agenda
- What is test-driven-development (TDD)?
- Basic concept of TDD
- Pro’s and con’s of TDD
- Need of test frameworks and unit tests
- What is a test framework?
- What is a unit test?
- Conclusion
- Live coding: Create StringUtil
What is test-driven-development (TDD)
- Original idea from NASA in Mercury project in 1960
- Mercury project was first try of NASA to send a real human to universe.
What is test-driven-development (TDD)
- Original idea from NASA in Mercury project in 1960
- Mercury project was first try of NASA to send a real human to universe.
- After a while this idea found its way back to development and was
mentioned in the book “Guide to better Smalltalk” from Kent Beck
What is test-driven-development (TDD)
- Original idea from NASA in Mercury project in 1960
- Mercury project was first try of NASA to send a real human to universe.
- After a while this idea found its way back to development and was
mentioned in the book “Guide to better Smalltalk” from Kent Beck
Xtreme Programming
SUnit - Smalltalk
JUnit - Java
Basic concept of TDD
- Test first!
- Write your test code first
- Afterwards write your code unter test
Basic concept of TDD
- Test first!
- Write your test code first
- Afterwards write your code unter test
- Red phase
- First test code has to fail
Basic concept of TDD
- Test first!
- Write your test code first
- Afterwards write your code unter test
- Red phase
- First test code has to fail
- Yellow/Blue phase
- Code under test was writen, test execution runs?
Basic concept of TDD
- Test first!
- Write your test code first
- Afterwards write your code unter test
- Red phase
- First test code has to fail
- Yellow/Blue phase
- Code under test was writen, test execution runs?
- Green phase
- Test execution works succeesfully and code under test is implemented
Pro’s of TDD
- Less code redundancy
Pro’s of TDD
- Less code redundancy
- No hidden features
Pro’s of TDD
- Less code redundancy
- No hidden features
- Clear API which can be tested
Pro’s of TDD
- Less code redundancy
- No hidden features
- Clear API which can be tested
- Code “security” and developer confidence raises
Pro’s of TDD
- Less code redundancy
- No hidden features
- Clear API which can be tested
- Code “security” and developer confidence raises
- Stability of main development branch/trunk
Pro’s of TDD
- Less code redundancy
- No hidden features
- Clear API which can be tested
- Code “security” and developer confidence raises
- Stability of main development branch/trunk
- Customer confidence
Con’s of TDD
- Costly development in time and resources
Con’s of TDD
- Costly development in time and resources
- Writing test code can be very complex
Con’s of TDD
- Costly development in time and resources
- Writing test code can be very complex
- IDE integration is very helpful
Con’s of TDD
- Costly development in time and resources
- Writing test code can be very complex
- IDE integration is very helpful
- More code to write
- Each line has positive and negative test code
Con’s of TDD
- Costly development in time and resources
- Writing test code can be very complex
- IDE integration is very helpful
- More code to write
- Each line has positive and negative test code
- Test framework API’s must be used
Need of test frameworks and unit tests
- You need a test framework to run automated test
Need of test frameworks and unit tests
- You need a test framework to run automated test
- Unit tests form the test suite
Need of test frameworks and unit tests
- You need a test framework to run automated test
- Unit tests form the test suite
- Developer has to adapt test framework usage
Need of test frameworks and unit tests
- You need a test framework to run automated test
- Unit tests form the test suite
- Developer has to adapt test framework usage
- Devide tests into unit, integration, scenario tests
- Test coverage tools needed
What is a test framework?
A test automation framework is an integrated system that sets the rules of
automation of a specific product. This system integrates the function libraries, test
data sources, object details and various reusable modules. These components act
as small building blocks which need to be assembled to represent a business
process. The framework provides the basis of test automation and simplifies the
automation effort
https://en.wikipedia.org/wiki/Test_automation#Framework_approach_in_automation
What is a test framework?
A test automation framework is an integrated system that sets the rules of
automation of a specific product. This system integrates the function libraries,
test data sources, object details and various reusable modules. These
components act as small building blocks which need to be assembled to represent
a business process. The framework provides the basis of test automation and
simplifies the automation effort
https://en.wikipedia.org/wiki/Test_automation#Framework_approach_in_automation
What is a unit test?
- Automated test to run code under test
What is a unit test?
- Automated test to run code under test
- Testing smallest unit of code in an application
What is a unit test?
- Automated test to run code under test
- Testing smallest unit of code in an application
- Code under test should have as little as possible dependencies to other
“units”
What is a unit test?
- Automated test to run code under test
- Testing smallest unit of code in an application
- Code under test should have as little as possible dependencies to other
“units”
- Each unit test should be independent
from others
What is a unit test?
- Automated test to run code under test
- Testing smallest unit of code in an application
- Code under test should have as little as possible dependencies to other
“units”
- Each unit test should be independent
from others
- Using mocks, stubs, spies
What is a unit test?
- Automated test to run code under test
- Testing smallest unit of code in an application
- Code under test should have as little as possible dependencies to other
“units”
- Each unit test should be independent
from others
- Using mocks, stubs, spies
- Can be used for documenation
What is a unit test?
- Automated test to run code under test
- Testing smallest unit of code in an application
- Code under test should have as little as possible dependencies to other
“units”
- Each unit test should be independent
from others
- Using mocks, stubs, spies
- Can be used for documenation
- Prove of concept for architecture
design and API
What is a unit test?
- Automated test to run code under test
- Testing smallest unit of code in an application
- Code under test should have as little as possible dependencies to other
“units”
- Each unit test should be independent
from others
- Using mocks, stubs, spies
- Can be used for documenation
- Prove of concept for architecture
design and API
Conclusion
- Unit testing is important. It helps to…
- reduce the costs of failure
Conclusion
- Unit testing is important. It helps to…
- reduce the costs of failure
- prove architecture and API
Conclusion
- Unit testing is important. It helps to…
- reduce the costs of failure
- prove architecture and API
- makes the usage of software clear
Conclusion
- Unit testing is important. It helps to…
- reduce the costs of failure
- prove architecture and API
- makes the usage of software clear
- But is also…
- difficult to write good tests
Conclusion
- Unit testing is important. It helps to…
- reduce the costs of failure
- prove architecture and API
- makes the usage of software clear
- But is also…
- difficult to write good tests
- a problem with higher test code complexity
Conclusion
- Unit testing is important. It helps to…
- reduce the costs of failure
- prove architecture and API
- makes the usage of software clear
- But is also…
- difficult to write good tests
- a problem with higher test code complexity
- consumption of time
Live coding
- String utility class in node.js
- Requirements:
- Build a single StringUtil class which should
- Chomp string left and right with given template strings
- LowerCase / UpperCase
- Provide fluent API
Test-driven-development
Thank you
&

Test driven development

  • 1.
    Test-driven-development How to developsoftware in high quality mode &
  • 2.
    Who is ? Hackerstolzis a young club from the Rhine-Neckar region. We organize Hackathons, promote the digital culture and advocate for more women in the IT field .
  • 3.
    Agenda - What istest-driven-development (TDD)? - Basic concept of TDD - Pro’s and con’s of TDD - Need of test frameworks and unit tests - What is a test framework? - What is a unit test? - Conclusion - Live coding: Create StringUtil
  • 4.
    What is test-driven-development(TDD) - Original idea from NASA in Mercury project in 1960 - Mercury project was first try of NASA to send a real human to universe.
  • 5.
    What is test-driven-development(TDD) - Original idea from NASA in Mercury project in 1960 - Mercury project was first try of NASA to send a real human to universe. - After a while this idea found its way back to development and was mentioned in the book “Guide to better Smalltalk” from Kent Beck
  • 6.
    What is test-driven-development(TDD) - Original idea from NASA in Mercury project in 1960 - Mercury project was first try of NASA to send a real human to universe. - After a while this idea found its way back to development and was mentioned in the book “Guide to better Smalltalk” from Kent Beck Xtreme Programming SUnit - Smalltalk JUnit - Java
  • 7.
    Basic concept ofTDD - Test first! - Write your test code first - Afterwards write your code unter test
  • 8.
    Basic concept ofTDD - Test first! - Write your test code first - Afterwards write your code unter test - Red phase - First test code has to fail
  • 9.
    Basic concept ofTDD - Test first! - Write your test code first - Afterwards write your code unter test - Red phase - First test code has to fail - Yellow/Blue phase - Code under test was writen, test execution runs?
  • 10.
    Basic concept ofTDD - Test first! - Write your test code first - Afterwards write your code unter test - Red phase - First test code has to fail - Yellow/Blue phase - Code under test was writen, test execution runs? - Green phase - Test execution works succeesfully and code under test is implemented
  • 11.
    Pro’s of TDD -Less code redundancy
  • 12.
    Pro’s of TDD -Less code redundancy - No hidden features
  • 13.
    Pro’s of TDD -Less code redundancy - No hidden features - Clear API which can be tested
  • 14.
    Pro’s of TDD -Less code redundancy - No hidden features - Clear API which can be tested - Code “security” and developer confidence raises
  • 15.
    Pro’s of TDD -Less code redundancy - No hidden features - Clear API which can be tested - Code “security” and developer confidence raises - Stability of main development branch/trunk
  • 16.
    Pro’s of TDD -Less code redundancy - No hidden features - Clear API which can be tested - Code “security” and developer confidence raises - Stability of main development branch/trunk - Customer confidence
  • 17.
    Con’s of TDD -Costly development in time and resources
  • 18.
    Con’s of TDD -Costly development in time and resources - Writing test code can be very complex
  • 19.
    Con’s of TDD -Costly development in time and resources - Writing test code can be very complex - IDE integration is very helpful
  • 20.
    Con’s of TDD -Costly development in time and resources - Writing test code can be very complex - IDE integration is very helpful - More code to write - Each line has positive and negative test code
  • 21.
    Con’s of TDD -Costly development in time and resources - Writing test code can be very complex - IDE integration is very helpful - More code to write - Each line has positive and negative test code - Test framework API’s must be used
  • 22.
    Need of testframeworks and unit tests - You need a test framework to run automated test
  • 23.
    Need of testframeworks and unit tests - You need a test framework to run automated test - Unit tests form the test suite
  • 24.
    Need of testframeworks and unit tests - You need a test framework to run automated test - Unit tests form the test suite - Developer has to adapt test framework usage
  • 25.
    Need of testframeworks and unit tests - You need a test framework to run automated test - Unit tests form the test suite - Developer has to adapt test framework usage - Devide tests into unit, integration, scenario tests - Test coverage tools needed
  • 26.
    What is atest framework? A test automation framework is an integrated system that sets the rules of automation of a specific product. This system integrates the function libraries, test data sources, object details and various reusable modules. These components act as small building blocks which need to be assembled to represent a business process. The framework provides the basis of test automation and simplifies the automation effort https://en.wikipedia.org/wiki/Test_automation#Framework_approach_in_automation
  • 27.
    What is atest framework? A test automation framework is an integrated system that sets the rules of automation of a specific product. This system integrates the function libraries, test data sources, object details and various reusable modules. These components act as small building blocks which need to be assembled to represent a business process. The framework provides the basis of test automation and simplifies the automation effort https://en.wikipedia.org/wiki/Test_automation#Framework_approach_in_automation
  • 28.
    What is aunit test? - Automated test to run code under test
  • 29.
    What is aunit test? - Automated test to run code under test - Testing smallest unit of code in an application
  • 30.
    What is aunit test? - Automated test to run code under test - Testing smallest unit of code in an application - Code under test should have as little as possible dependencies to other “units”
  • 31.
    What is aunit test? - Automated test to run code under test - Testing smallest unit of code in an application - Code under test should have as little as possible dependencies to other “units” - Each unit test should be independent from others
  • 32.
    What is aunit test? - Automated test to run code under test - Testing smallest unit of code in an application - Code under test should have as little as possible dependencies to other “units” - Each unit test should be independent from others - Using mocks, stubs, spies
  • 33.
    What is aunit test? - Automated test to run code under test - Testing smallest unit of code in an application - Code under test should have as little as possible dependencies to other “units” - Each unit test should be independent from others - Using mocks, stubs, spies - Can be used for documenation
  • 34.
    What is aunit test? - Automated test to run code under test - Testing smallest unit of code in an application - Code under test should have as little as possible dependencies to other “units” - Each unit test should be independent from others - Using mocks, stubs, spies - Can be used for documenation - Prove of concept for architecture design and API
  • 35.
    What is aunit test? - Automated test to run code under test - Testing smallest unit of code in an application - Code under test should have as little as possible dependencies to other “units” - Each unit test should be independent from others - Using mocks, stubs, spies - Can be used for documenation - Prove of concept for architecture design and API
  • 36.
    Conclusion - Unit testingis important. It helps to… - reduce the costs of failure
  • 37.
    Conclusion - Unit testingis important. It helps to… - reduce the costs of failure - prove architecture and API
  • 38.
    Conclusion - Unit testingis important. It helps to… - reduce the costs of failure - prove architecture and API - makes the usage of software clear
  • 39.
    Conclusion - Unit testingis important. It helps to… - reduce the costs of failure - prove architecture and API - makes the usage of software clear - But is also… - difficult to write good tests
  • 40.
    Conclusion - Unit testingis important. It helps to… - reduce the costs of failure - prove architecture and API - makes the usage of software clear - But is also… - difficult to write good tests - a problem with higher test code complexity
  • 41.
    Conclusion - Unit testingis important. It helps to… - reduce the costs of failure - prove architecture and API - makes the usage of software clear - But is also… - difficult to write good tests - a problem with higher test code complexity - consumption of time
  • 42.
    Live coding - Stringutility class in node.js - Requirements: - Build a single StringUtil class which should - Chomp string left and right with given template strings - LowerCase / UpperCase - Provide fluent API
  • 43.