Or do they just mean doing unit tests as you code?
I'm never sure when I hear this term because the benefits described (thing's just working first try) seem to apply no matter what order do it in.
Or do they just mean doing unit tests as you code?
I'm never sure when I hear this term because the benefits described (thing's just working first try) seem to apply no matter what order do it in.
TDD, though, is really a learning system. The main point is writing the code with testability in mind. You can write them together and get the same results as long as you do that. It keeps the code loosely coupled and the APIs clean.
So, IMO, you can still call it TDD as long as you are writing the code and tests together and are writing the code with the tests in mind. You can do that with the pure TDD or with some variant as long as the result is the same. I guess it depends whether you are referring to the general style or the specific learning methodology.
Because, what exactly is the contract? Do I essentially write integration tests to the effect of "If I click input element with css class .username, type 'x', and then click input element with class .password, then type 'y', then click the button with class .login, the page URL has changed from <mysite.com>/login to <mysite.com>/profile?"
There are no clear API interfaces for UIs. A user wouldn't really care that the button had class .username on it, for example -- that just gives us some way to identify the correct DOM element to perform the e2e test against. And some day, a developer could rename that class name, and it'd break the e2e test.
In other words, I can't assumption what TDD looks like for user interfaces, without the whole testing process seeming extremely brittle. Contrast this with, if I call some REST API, I expect this response body. It's quite concrete.
Unless you are trying to test whether clicking on a button or link fires an event, UI tests aren't exactly in the domain of unit tests.
Having seen some of the interesting designs of less-experienced devs, I disagree that this is a benefit of TDD. TDD may help straighten out some of your thoughts if you already have loose coupling in mind, but it won't work if the dev doesn't already have some experience there.
At a very high level: Write the most basic case and it will fail (no code written). Write code so the test passes.
Now write another test that will fail. Then write code so that tests passes.
It forces you to write code in a way that is testable and you catch any regressions if previous tests fail.
In the end... you shouldn't.... write any code that isn't required to pass a test.
Did you made any effort to adopt and enforce TDD? Because, like any good practice, unless someone drives adoption then things tend to stay the way they are.
In my experience, it has always been easier for multiple developers working on a code base to write the tests once the implementation has been fleshed out and a significant portion of it is 'ready'.
If you deliver a set of scripted requirements (Read documentation) prior to the feature - that’s TDD.
If you change the code, you break the documentation.