Introducción al Test Driven Development (TDD)

TDD, es el término que se obtiene de las siglas de Test Driven Development. Fue creado por Kent Benck, el mismo que inventó Extreme programming y JUnit.

TDD, es una metodología de desarrollo, que se basa principalmente en el desarrollo guiado por pruebas. Es decir, escribir pruebas antes de escribir código. Debido a que el nombre de esta metodología comienza por Test, son muchas las personas que se confunden y lo familiarizan equivocadamente con una metodología de testing.

Esta metodología, envuelve toda la fase del desarrollo. El primer paso, está enfocado, está orientado a desarrollar primeramente pruebas (que generalmente son unitarias). El segundo paso, posteriormente, busca el desarrollar un código que pase satisfactoriamente la prueba. Finalmente, el tercer paso consiste en refactorizar el código escrito.

Ciclo de vida de un desarrollo TDD

Las fases del desarrollo o como también es conocido, ciclo de vida de desarrollo en metodología TDD. Se basa en la siguiente estructura:

  1. Rojo: en esta fase del TDD, el código falla al realizar la prueba (codificación/desarrollo de pruebas).
  2. Verde: en esta fase del TDD, se desarrolla el código que pasa la prueba exitosamente (desarrollo del código que pase la prueba)
  3. Refactorizar: en esta fase del TDD, se refactorizar el código eliminando la redundancia (limpiarlo).

El concepto de TDD se basa en un ciclo que se repite a modo de bucle constantemente. Hasta que llegamos al punto donde tenemos un código que cumple los requisitos y que pasa los test y a su vez está refactorizado.

En TDD el testing, siempre va por delante de la codificación.

Beneficios del TDD:

Algunos beneficios del TDD:

  • Mejora la comunicación entre los integrantes de un equipo de desarrollo para poder solventar los problemas.
  • Evitamos escribir código innecesario.
  • Código con más calidad y más robusto.
  • Análisis de requisitos antes de comenzar a picar código.
  • La refactorización constante, otorga limpieza a nuestro código.
  • Debugging, el estar constantemente pasando verificaciones que someten constantemente a nuestro código a los peores casos, nos permite detectar bugs (errores), y minimizarlos al máximo en nuestro código de una forma sencilla.
  • Que se traducen en menos errores y por tanto, mayor rapidez y productividad.

Pese a todos estos beneficios, a los programadores nos suele echar para atrás usar esta metodología. Ya que habitualmente solemos ponernos a picar código directamente sin ni siquiera analizar los requisitos de un proyecto. Y tendemos a pensar que el TDD hace que el desarrollo de un proyecto se vuelva lento y pesado, aunque si se aplica correctamente, el resultado no es este, como se puede apreciar en la siguiente imagen.

¿Puedo probar un algoritmo que no he escrito aún? Sí, y precisamente buscamos que el test fallé “que se ponga en Rojo”, para posteriormente, solventarlo mediante el código y una vez pasamos el test exitosamente, “que se ponga en verde”. Y finalmente refactorizamos, y testeamos de nuevo. Y si no tenemos que continuar desarrollando el código detenemos el bucle en ese ciclo.

El sudoku, un ejemplo real de TDD

Para acabar de digerir el concepto, un ejemplo de TDD que realizamos en nuestra vida cotidiana sin darnos cuenta, podría ser la realización de un sudoku. Si nos fijamos, primeramente, vamos testeando números, que fallan el testing. Hasta que llegamos al punto donde encontramos uno que sí que pasa dicho test. Si posteriormente vemos un número dos veces, iríamos al tercer paso, el refactorizar.

En próximos artículos, veremos ejemplos prácticos de cómo aplicar el TDD como metodología de desarrollo de software.

56 comentarios

  1. Hi to all, since I am genuinely keen of reading this
    web site’s post to be updated regularly. It carries nice

  2. Hello to every , for the reason that I am truly eager of reading this blog’s post to be updated regularly.
    It carries nice information.

  3. I like what you guys are up also. Such smart work and reporting!
    Keep up the excellent works guys I’ve incorporated you
    guys to my blogroll. I think it’ll improve the value of my website :

    My homepage: Infinuity CBD Gummies (

  4. As the admin of this site is working, no uncertainty very rapidly it will be renowned, due to its quality contents.

    Here is my website Luiresse Skin Review

  5. I’m not sure exactly why but this weblog is loading extremely slow for me.
    Is anyone else having this problem or is it a problem on my end?
    I’ll check back later on and see if the problem still exists.

    Feel free to visit my blog post – Luiresse Skin Review

  6. I’ve recently started a website, the info you offer on this site has helped me greatly.
    Thank you for all of your time & work.

    Here is my web page Sparkling Pure CBD Gummies

  7. Hey just wanted to give you a quick heads up. The text in your
    post seem to be running off the screen in Safari.

    I’m not sure if this is a format issue or something to do with browser compatibility but I figured I’d post
    to let you know. The design look great though! Hope you get the problem resolved soon. Kudos

    Feel free to visit my web-site: IceHouse Portable AC Reviews (

  8. great issues altogether, you simply gained a logo new reader.
    What would you recommend about your post that you simply
    made some days in the past? Any positive?

    my web blog; Infinuity CBD Gummies;,

  9. Woah! I’m really digging the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s difficult to get
    that “perfect balance” between superb usability and
    visual appeal. I must say that you’ve done a
    amazing job with this. In addition, the blog loads very quick for me on Safari.
    Exceptional Blog!

  10. Great post. I used to be checking constantly this blog and I am impressed!
    Very helpful info specifically the final section 🙂 I handle such info much.
    I was looking for this particular info for a long time.
    Thanks and good luck.

  11. Hi there! This is my first visit to your blog!
    We are a team of volunteers and starting a new project in a community in the same niche.
    Your blog provided us useful information to
    work on. You have done a wonderful job!

  12. What a data of un-ambiguity and preserveness of precious
    familiarity about unpredicted feelings.

    Here is my site – Molten Keto Garcinia

  13. Good information. Lucky me I came across your site by
    accident (stumbleupon). I have book marked it for later!

    Have a look at my web-site :: Hydrofirm

  14. I’m not sure where you are getting your info, but great
    topic. I needs to spend some time learning more or understanding more.
    Thanks for fantastic info I was looking for this information for
    my mission.

  15. We wish to thank you once again for the lovely ideas you
    offered Jeremy when preparing a post-graduate research plus, most importantly, for providing
    every one of the ideas in a blog post. Provided that we
    had known of your web page a year ago, we might have been saved the pointless measures
    we were taking. Thanks to you.

    My page … Vigor Max Male Enhancement (

  16. Hi there, I discovered your blog by the use of Google even as looking for a similar subject, your
    web site came up, it seems to be great. I’ve bookmarked it in my google bookmarks.[X-N-E-W-L-I-N-S-P-I-N-X]Hello there, just become alert to your blog through Google, and located that
    it’s really informative. I’m going to watch out
    for brussels. I will be grateful if you happen to proceed
    this in future. Many other people can be benefited from your
    writing. Cheers!

    Look into my blog post Aizen Power Review

  17. Dead indited content material, regards for information.

    Also visit my web-site – Jim

  18. Hey! I know this is kinda off topic but I was wondering if you knew where I could locate a
    captcha plugin for my comment form? I’m using the same blog platform
    as yours and I’m having trouble finding one? Thanks a lot!

    Take a look at my homepage :: Eagle Hemp CBD Gummies,,

  19. Thank you for any other great post. Where else may just anyone get that kind of information in such an ideal means of writing?
    I have a presentation subsequent week, and I am at the search for such information.

  20. Enjoyed studying this, very good stuff, thanks.

    Take a look at my website :: TetraMale Reviews

  21. This is very interesting, You are an excessively professional blogger.
    I’ve joined your feed and look forward to looking for more of your excellent post.
    Additionally, I have shared your web site in my social networks!

    my blog – Niva CBD Gummies

  22. But wanna tell that this is very beneficial, Thanks for
    taking your time to write this.

    My web site … Renown CBD

  23. hello!,I really like your writing very much! percentage we be in contact
    extra about your article on AOL? I require a specialist in this house to solve my problem.
    Maybe that is you! Having a look forward to peer you.

    my blog post: Ketorol Review

  24. It’s actually a nice and useful piece of information. I am happy that you shared this useful information with us.

    Please stay us up to date like this. Thanks for sharing.

  25. Great post. I will be experiencing some of these issues as well..

  26. Some truly interesting info, well written and broadly user pleasant.

    Also visit my homepage – Luiresse Reviews

  27. Hi there! I just wanted to ask if you ever have any issues with hackers?
    My last blog (wordpress) was hacked and I ended up losing
    a few months of hard work due to no data backup. Do you have any methods to
    protect against hackers?

    Here is my site Far East XL Ingredients

  28. What i don’t realize is if truth be told how
    you’re no longer really a lot more neatly-favored than you may be right now.
    You’re very intelligent. You recognize therefore significantly relating to this topic, made me individually believe it from so many varied angles.

    Its like men and women are not interested until it’s
    one thing to accomplish with Woman gaga! Your individual stuffs great.

    Always care for it up!

    my web-site;

  29. Hello! Someone in my Myspace group shared this site with us so I came to take a look.
    I’m definitely enjoying the information. I’m book-marking
    and will be tweeting this to my followers!
    Superb blog and great style and design.

    my homepage: Molten Keto Garcinia

  30. I am sure this piece of writing has touched all the internet users, its really really nice
    piece of writing on building up new weblog.

    Here is my webpage – Elisa

  31. I visited multiple web pages but the audio feature for audio songs existing at this web page is
    in fact excellent.

    Here is my web blog :: Optimum Keto Review

  32. Attractive section of content. I just stumbled upon your blog and in accession capital to assert that
    I get actually enjoyed account your blog posts. Any way I will be subscribing to your
    feeds and even I achievement you access consistently

    Look into my homepage –

  33. Great goods from you, man. I have understand your stuff previous to and you are just
    too wonderful. I really like what you’ve acquired here, really like what you are stating and
    the way in which you say it. You make it enjoyable and you still care for to keep it wise.

    I cant wait to read much more from you. This is actually a wonderful
    web site.

    my web site: Optimum Keto Pills (

  34. I have been browsing on-line more than three hours lately, but I by no means found
    any interesting article like yours. It’s lovely worth sufficient for me.
    Personally, if all web owners and bloggers made just right content as you did,
    the net will likely be a lot more useful than ever before.

  35. Fastidious answers in return of this issue with real arguments and describing the whole thing regarding that.

    Also visit my page – Insights CBD Gummies

  36. You actually make it appear really easy along with
    your presentation however I to find this topic to be really something which I feel I would never understand.
    It kind of feels too complicated and extremely vast for me.
    I am taking a look ahead in your next submit, I’ll try to get
    the dangle of it!

    Here is my web page :: True Burn Keto Reviews

  37. Hi! Do you know if they make any plugins to protect against hackers?
    I’m kinda paranoid about losing everything I’ve worked hard on. Any tips?

    Review my web-site :: Pure Keto Burn Pills

  38. Very descriptive blog, I enjoyed that a lot. Will there be a part 2?

    my page Biodermeux Review []

  39. Pretty section of content. I just stumbled upon your weblog and in accession capital
    to claim that I acquire actually loved account your blog posts.
    Anyway I’ll be subscribing on your feeds or even I success you access constantly quickly.

    Visit my page Artctic Box AC

  40. Perfect work you have done, this internet site is really cool with great

    Review my website :: Bio Shed Keto Reviews (

  41. I’m truly enjoying the design and layout of your blog. It’s a very easy on the eyes which makes it much more enjoyable for me to come here and
    visit more often. Did you hire out a designer to create your theme?
    Outstanding work!

    Look into my blog post :: Wawza Apple Cider Gummies Review

  42. Thanks so much regarding giving me an update on this topic on your website.
    Please be aware that if a fresh post appears or if any alterations occur about the current publication,
    I would be thinking about reading a lot more and finding out how
    to make good utilization of those strategies you talk about.
    Thanks for your time and consideration of other folks by making your blog available.

    Here is my webpage: Niva CBD Gummies Reviews,,

  43. I will immediately seize your rss feed as I can’t to find your email subscription link or e-newsletter service.
    Do you have any? Kindly let me realize so that I may subscribe.

    Here is my webpage :: Insights CBD Review

  44. Have you ever thought about adding a little bit more than just your articles?
    I mean, what you say is fundamental and all. But just imagine if you added some great photos or video
    clips to give your posts more, “pop”! Your content is excellent
    but with images and videos, this site could certainly be one of the most beneficial in its field.
    Superb blog!

  45. I am sure this paragraph has touched all the internet people, its
    really really nice post on building up new web site.

    Here is my site: Natural Burn Keto

  46. I just like the helpful information you provide in your articles.
    I will bookmark your blog and take a look at once more right here frequently.
    I am moderately certain I will be told many new stuff proper right here!
    Good luck for the next!

    Also visit my page;

  47. Simply desire to say your article is as surprising. The clearness in your post is just excellent and i could assume
    you are an expert on this subject. Well with your
    permission allow me to grab your feed to keep updated with forthcoming post.

    Thanks a million and please carry on the rewarding work.

  48. Hello.This post was really motivating, particularly because I was searching
    for thoughts on this matter last Thursday.

    my blog post :: Brilliance Keto

  49. Wonderful beat ! I would like to apprentice while you amend your web site, how could i
    subscribe for a blog website? The account aided
    me a acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright
    clear idea

  50. I likewise conceive thence, perfectly pent post!

    Feel free to surf to my page; Gold Leaf CBD Gummies

  51. It is really a great and useful piece of info.
    I’m happy that you just shared this helpful info with us.
    Please stay us informed like this. Thank you for sharing.

  52. Ridiculous quest there. What occurred after? Good luck!

    my web page: Rodger

  53. Some truly nice and useful information on this
    web site, besides I think the style and design contains
    superb features.

    Take a look at my site;

  54. Hi there! Quick question that’s completely off topic.

    Do you know how to make your site mobile friendly?
    My blog looks weird when viewing from my apple iphone. I’m trying to find
    a theme or plugin that might be able to resolve this problem.
    If you have any suggestions, please share. Cheers! asmr asmr

  55. I’ll immediately grasp your rss feed as I can’t find your
    e-mail subscription hyperlink or e-newsletter service.
    Do you’ve any? Kindly permit me recognize so that I may subscribe.

    My web site – carbohydrate intake

  56. What a data of un-ambiguity and preserveness of precious experience concerning unpredicted emotions.

    Review my webpage; sweet potato diet

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

La Ley 34/2002 nos obliga a avisarte de que usamos cookies propias y de terceros con objetivos estadísticos y de sesión y para mostrarte la 'publi' que nos da de comer. Tranquilo, este mensaje solo sale una vez. Más información

Java desde 0 comunica a los usuarios, a través de este aviso, que puede utilizar cookies cuando el usuario navega por las diferentes pantallas y páginas del sitio. Durante el uso de nuestra página Web usted acepta y autoriza expresamente el uso de cookies, de acuerdo con nuestra Política de Privacidad. Este sitio web utiliza las siguientes cookies propias: - Cookies de sesión, para garantizar que los usuarios que escriban comentarios en el blog sean humanos y no aplicaciones automatizadas. De esta forma se combate el spam. Este sitio web utiliza las siguientes cookies de terceros: - Google AdManager y AdSense: Utiliza cookies para mejorar la publicidad. Entre otros fines, suelen utilizarse para segmentarla según el contenido que sea relevante para los usuarios o su ubicación, mejorar los informes de rendimiento de las campañas y evitar mostrar anuncios que los usuarios ya hayan visto. Las cookies no contienen información personal identificable. Consulta cómo utiliza Google la información de sitios web o aplicaciones. y cómo bloquear determinados anuncios. - Google Analytics: Almacena cookies para poder elaborar estadísticas sobre el tráfico y volumen de visitas de esta web. Al utilizar este sitio web está consintiendo el tratamiento de información acerca de usted por Google. Por tanto, el ejercicio de cualquier derecho en este sentido deberá hacerlo comunicando directamente con Google. - Redes sociales: Cada red social utiliza sus propias cookies para que usted pueda pinchar en botones del tipo Me gusta o Compartir.