Test Driven Development

I saw some talks on YouTube about TDD.
Though it seems really helpful it probably requires a great amount self-control.

Is anybody here using it either personally or at work?
Do you think it's really beneficial?
Do you like using it?
Is anybody here using it either personally or at work?
Yes.
Do you think it's really beneficial?
Yes.
Do you like using it?
Depends.

The point of this kind of development isn't that much that you find more bugs.
The point is that you need to create classes/function that are simple enough so that it can be tested. Normally within a program all classes/functions are connected to make it work. So for TDD you need as many isolated functions/classes as possible to make it testable.

This is much more effort and time consuming. Sometimes it can't be done due to the lack of time. But the good think would be that - used consequently - you have a lot of reusable code.

The second time consuming part would be writing the test. You need a strategy to cover as many cases as possible.
Having tests is great when you have a product that is developed against requirements. You write tests for how something should work. Then, when someone else changes the code, if it makes a test fail then you know you broke some requirement or existing functionality. In theory.

The problem with tests are that it can act as friction against actually changing your software, if they aren't written "well" or if they are over-specified. Sometimes, the unit test just gets in the way of making a future change, so the developer then changes the test case... It's an art of being specific enough to initially test against when developing or maintaining, but not too specific such that it breaks a test case even though nothing is wrong with the actual software itself.

By the way, you don't need some complicated testing framework to do tests. What I do at home is I have a separate exe I compile, but it connects to a portion of the same code as the main project, so after building the main project, I can run my test exe.
Last edited on
I think test are absolutely necessary, and I write them all the time, but TDD is a joke.
Thanks all for your input.

The problem with tests are that it can act as friction against actually changing your software, if they aren't written "well" or if they are over-specified


Shouldn't tests encourage you more to change the code since you can easily see if you broke sth.

What I do at home is I have a separate exe I compile, but it connects to a portion of the same code as the main project, so after building the main project, I can run my test exe.

In doctest you can have your test code inside your production code and you can run either the tests, your code or both. The tests can serve then also as a documentation.

@Cubbi, why do you see TDD as a joke?
Like anything else, TDD can be any of {a useful tool for some projects, used incorrectly, a fad, a huge mess used incorrectly, useless for some project types}.

Its usually seen for mature software (that is, there is an existing working version) with a large team, from my experience.
Last edited on
because letting tests actually *drive* development, that is, coding to pass tests, is wrong. At best, it produces unmaintainable, rigid, and poorly-tested (irony) throwaway code.
In theory is that you write tests based on what you need the component to do (e.g. sending a user email should call this email component), but in my experience it's very difficult to write the test/the fake objects etc. correctly without knowing what the code is even doing.

E.g. how can I determine what the subject of this email is without knowing the user information? Well that means I need the user component that I didn't think I would need until I thought about it, etc.
Last edited on
Cubbi wrote:
TDD is a joke

The best song Public Enemy never wrote?
Topic archived. No new replies allowed.