login
Blurts on the Art of Software Development

Today | RSS | RDF | Atom | Other Tags
Categories : All | All | CI | .NET | General | Humour | Java | Personal | Reviews | Ruby | SW Eng

Someone once sent the following comment on the slides of a TDD classroom training I had done for his company (that someone wasn't attending himself and just checked out the slides from their intranet):

When thinking about TDD I always think about Kent Beck sentence "throw away all my production code but keep my test code" (not verbatim), the principle is that it should be possible to generate production code on the basis of only test code.

Which raises the question, has anyone tried that? While I'm pretty suspicious about such an idea scaling up to "real" systems, it would be interesting to read about academic experiments or something like that. Would it be even theoretically feasible to generate seemingly random bytecode until all the tests just happen to pass (and we'd know we have a working implementation of the system as described by the tests)?


I have had similar thoughts since I read about testing tool called Jester (http://jester.sourceforge.net/). My conclusion was that production code generation from tests is not going to work very well. The problem is that unit tests are by nature white-box tests. For example if we know that code under execution is using a loop, we need only tests for one randomly selected nominal case and few tests for boundary cases. Code generator can then generate code that does not use loop but instead it just returns correct values for all the test cases. So it passes all the tests, but it won't work with other nominal cases at all. Code generator has no way to figure out this "implicit wisdom" from test cases.
Check out ADATE. Currently it seems the specification files used to generate functions are a lot longer than the generated functions themselves, so no need to start worrying about your job being done by robots quite yet.


Add a comment

Title
Body
HTML : b, i, blockquote, br, p, pre, a href="", ul, ol, li
Math Quiz 4 + 3 = (Helps stop blog spam)
Name
E-mail address
Website
Remember me Yes  No 

E-mail addresses are not publicly displayed, so please only leave your e-mail address if you would like to be notified when new comments are added to this blog entry (you can opt-out later).

TrackBack to http://radio.javaranch.com/lasse/addTrackBack.action?entry=1121114435941