DEV Community

Discussion on: Explain Unit Testing like I'm five

 
nestedsoftware profile image
Nested Software • Edited

Hi Hila, the nice thing about TDD is that it's a clear and well defined concept. You write a test. Test fails. You write the code to pass the test. You refactor to clean things up. You write another test, and so on.

What about BDD? Well, I am not an expert, but I see BDD as kind of a generalization, maybe an extension as well. For one thing, BDD doesn't usually use the word "test" even when talking about what is essentially a unit test. BDD tries to emphasize the desired behaviour of the application, and as such it encompasses both what we'd call "unit" tests, i.e. small-scale tests of logic, as well as maybe "integration" tests, i.e. higher-level functionality of the system as a whole.

I get a sense that some of BDD is not so much about writing code as it is about opening communication channels between developers and people who are driving the requirements, such as users, business people, or managers.

I don't think that BDD is as well-defined as TDD, and as such there is potentially more room for confusion or disagreement.

Some links:

Thread Thread
 
hilaberger92 profile image
Hila Berger

Thanks!
what about legacy code? what is your definition for that?

Thread Thread
 
nestedsoftware profile image
Nested Software • Edited

Usually the term "legacy code" refers to an older codebase that’s still in use but the technology is considered somewhat outdated and therefore poses greater maintenance difficulties. It does not seem to be related to BDD though. If your question was related to BDD somehow, please clarify.

Thread Thread
 
hilaberger92 profile image
Hila Berger

It's not related to BDD. Legacy code has many definitions, so I wanted to know what's yours :)
My favorite definition is:"Code you are afraid to change".