Code Monkey home page Code Monkey logo

java-mod-3-tdd's Introduction

Test Driven Development

Learning Goals

  • Introduce Test-Driven Development (TDD).
  • Explain the benefits of TDD.

Introduction to Test Driven Development

Test Driven Development (TDD) is the practice of writing unit tests prior to implementing the functionality that is meant to be tested. This may sound counter-intuitive, but it has the following benefits:

  • Unit testing forces us to think about the structure of the code and making sure the code is written in a way that it can actually be tested. Going through that process prior to actually writing the code saves time and leads to better written software sooner.
  • It forces us to have the mindset of "if we cannot test it, we cannot write the code." We cannot write code that isn't covered by unit tests.

The common steps to TDD are the following:

  1. Write a unit test to test a certain functionality.
  2. Run the test (which will fail the first time around since we have not written any code yet in the program).
  3. Write some code and/or refactor the code to make the test pass.
  4. Execute the test(s) again and see if it passes.
    1. If it does not, go back and refactor the code until it does pass.
  5. Repeat the following steps by adding unit tests any time we want to add additional features or functionality.

Below is a diagram illustrating the lifecycle of test driven development:

tdd-cycle

Note that we "stop" or end the cycle when we are finished developing the program.

java-mod-3-tdd's People

Contributors

alveem avatar kcleland0818 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.