"Test-driven software development", not related to test

zhaozj2021-02-08  477

Test-Driven Development Is Not About Testing

November 3, 2003

Summary

I am always on the look out for good questions to ask candidates in an interview. Not the "How many oranges can I fit in this room?" Kind of nonsense (the stock response to which is apparently "with or without us standing in it ").

By Dan North

Page 1 of 1

I am always on the look out for good questions to ask candidates in an interview. Not the "How many oranges can I fit in this room?" Kind of nonsense (the stock response to which is apparently "with or without us standing in it ? "). Nor the picky, encyclopedic type such as" In the javax.obscure.DustyCorner class, which method throws a FullyDocumentedException? "(If you do not respond with" I would check the Javadocs "on the grounds that you actually know You real ught to get out more.)

Instead, I like the sort of technical question that allows candidates to demonstrate real insight;. Where they can show not only technical depth and breadth, but also a mature understanding of the software development process So I was delighted when a colleague offered me a perfect Interview Question, Namely: "What is the point of test-driven development?"

Test-driven development (TDD) has grown out of the Agile software movement (www.agilealliance.org) and Extreme Programming (XP) in particular. Extreme Programming stipulates a set of best practices that collectively encourage core values ​​such as feedback and simplicity. The feedback occurs in the form of tests, by delivering in short iterations, and by the simple expedient of talking to one another The simplicity comes from the process of refactoring -. ruthlessly - and from only delivering exactly what the software has to do right now .Kent Beck, the original champion of XP, has extracted the essence of its development practices and named it test-driven development. and so to the model interview answer. The point of TDD is to drive out the functionality the software actually needs, rather THAN What The Program This Seems At First CounTuitive, IF Not DownRight Silly, But It Not Only Makes Sense, IT Also Quickly Becomes a Natural And Elegant Way to Develop Software.

We start by writing some client code as though the code we want to develop already existed and had been written purely to make our life as easy as it could possibly be This is a tremendously liberating thing to do:. By writing a model client for our .

Obviously this will not even compile, and this is the counterintuitive part -! The code that will sit on the other side of the API does not even exist yet The next stage is to write the minimum amount of code to get the test compiling . That's all, just a clean compile, so you can run the test (which at this stage will fail). IDEs such as IntelliJ IDEA or the open source Eclipse will generate missing classes and implement missing methods for you. now, and only now , you write the application code to satisfy the test The final piece of the puzzle is to refactor the code so it's as simple as it can be This then becomes your development rhythm:.. write a test, write some code, refactor.Writing the test before you write the code focuses the mind - and the development process -. on delivering only what is absolutely necessary in the large, this means that the system you develop does exactly what it needs to do and no more This in turn means that. IT is easy to modify to make it do more things in The Future As They Are Driven Out by More Tests.

We keep the tests we wrote and run all of them, often, to make sure the system does everything it is supposed to do (and to alert ourselves immediately if we break any existing functionality). However, the extremely useful test suite we've Created Is Very Much A Secondary Benefit of the TDD Process.

So when you're sitting in an interview and someone asks you about testdriven development, remember that it's not about the tests; it's about seeing how little you actually need to do and how cleanly you can do it If someone asks you to fill a! Room with Oranges? Well, I'll Leave That To you.

What do you think? Join the feedback to this item.

转载请注明原文地址:https://www.9cbs.com/read-725.html

New Post(0)