File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Agile and Other Processes and the fly likes How do you do test driven development? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Agile and Other Processes
Bookmark "How do you do test driven development?" Watch "How do you do test driven development?" New topic
Author

How do you do test driven development?

Valeh H Nasser
Greenhorn

Joined: Jul 19, 2010
Posts: 4
Hi, I am doing research on what tools can make TDDier's lives easier.
If you are a developer who practices "test driven development" (TDD) please answer the following questions.

Thanks a lot!

Instructions:
Please specify which of the following statements hold when you are modifying existing unfamiliar code or extending it with new functionality:
Please use seldom/sometime/usually or true/false values:
Example: I read tests to understand the program : sometimes

Questions:
1- I read tests to understand the program:
2- I run tests and trace them to understand the program:
3- Before I make any changes to the code, I first discover tests that are relevant to the functionality of interest and then make the changes:
4- I do not try to find the relevant tests. Instead, I write a set of new tests from scratch and then make changes to the code to pass them. I fix any other failing tests later:
5- I change the program code and then change and augment all the broken tests:

Other:

Copy Right: Valeh H. Nasser, 2010
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

I don't know if this will fit your questions but, if I have to add a new method I would start from the assert. Like Kent Becks book says it will give us a better view of the test by doing that.

But, I can't answer the first question, why should I read code to understand the software? If the software is well designed the class and its methods will be able to explain itself.

About the second it's too vague. We can do a lot of those options or just one of it.


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Valeh H Nasser
Greenhorn

Joined: Jul 19, 2010
Posts: 4
Thanks for your reply. I just simplified the question so that it gets easier to answer.
Valeh H Nasser
Greenhorn

Joined: Jul 19, 2010
Posts: 4
Here is the modified question:

Instructions:
Please specify which of the following statements are true when you are modifying existing unfamiliar code or extending it with new functionality in a TDD project:
Please use a number from 1 to 5 where 1 is never and 5 is always.

Example: I read tests to understand the program : 2

Questions:
1- I read tests to understand the program:
2- I run tests and trace them to understand the program:
3- I change the program code and then change and augment all the broken tests:
4- Before I make any changes to the code, I first discover and make changes to tests that are relevant to the functionality of interest and then make the changes to the code to pass them:
5- I do not try to find the relevant tests. Instead, I write a set of new tests from scratch and then make changes to the code to pass them. Then I fix any other broken tests later:
Other:

Copy Right: Valeh H. Nasser, 2010
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30506
    
150

I do TDD about half the time.

1- I read tests to understand the program: 3 (sometimes; often the code is readable and this isn't necessary - or I've seen it before)
2- I run tests and trace them to understand the program: 1 (never)
3- I change the program code and then change and augment all the broken tests: 2 (rarely)
4- Before I make any changes to the code, I first discover and make changes to tests that are relevant to the functionality of interest and then make the changes to the code to pass them: 3 (sometimes - I think; see comment below)
5- I do not try to find the relevant tests. Instead, I write a set of new tests from scratch and then make changes to the code to pass them. Then I fix any other broken tests later: 4 (often)

For #4, discovery sounds formal; like I track down all the relevant tests. Usually one is relevant and I change that and see if others are affected. And then analyze whether they should change or not.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Valeh H Nasser
Greenhorn

Joined: Jul 19, 2010
Posts: 4
Thanks for your reply. Do you think IDE's do a good job helping tracking with relevant tests or do you wish to get more intelligent support?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30506
    
150

Valeh H Nasser wrote:Thanks for your reply. Do you think IDE's do a good job helping tracking with relevant tests or do you wish to get more intelligent support?

For the one test that needs addition/changing before I touch the code, it is almost always immediately apparent. Also, I run all my unit tests when something changed so this isn't a big problem. Infinitest does track which tests are affected when I change code and they do a good job of that.
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
Jeanne Boyarsky wrote:Also, I run all my unit tests when something changed so this isn't a big problem. Infinitest does track which tests are affected when I change code and they do a good job of that.


Hi Jeanne--

Have you been using Infinitest against a larger code base with some slower tests? I'm curious to know how that's been panning out. I've used it on a smaller, well-design effort where a small number of tests (~1000) all ran in a couple seconds, and it's fantastic, particularly in terms of how it makes you think about how testing fits into the development cycle.

thanks
Jeff


Books: Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30506
    
150

Jeff,
I'm only using Infinitest on my JavaRanch stuff. Which is small in the scheme of things. The largest project we have is the software for this forum. Much smaller than a work project.

I'm not using it at work. I think I'm less concerned at work because there we have an automated build to pick up on failing tests in the rare event I manage to miss one. Also, my work machine is more powerful so I can run all the (thousands) of unit tests that go with the workspace in a couple seconds. It takes longer than that to think what I want to do next, so I don't notice it.
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
Jeanne Boyarsky wrote:I'm not using it at work. I think I'm less concerned at work because there we have an automated build to pick up on failing tests in the rare event I manage to miss one. Also, my work machine is more powerful so I can run all the (thousands) of unit tests that go with the workspace in a couple seconds. It takes longer than that to think what I want to do next, so I don't notice it.


Wish I had that problem. :-) I'm now in C# land and it takes half a minute just to wait for builds, plus our test suite takes 10 minutes to run ~8000 tests. Lots of work ahead on speeding things up...

Jeff
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30506
    
150

Wow. That's slow. Our integration tests do take longer of course, but even those don't take 10 minutes except for the largest apps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you do test driven development?