4 ms·
Semantically (and probably officially) that's not really 'test first'. You wrote something else (html) then wrote a test for that. You should be writing a tes
by mgkimsal 14y ago
Semantically (and probably officially) that's not really 'test first'. You wrote something else (html) then wrote a test for that. You should be writing a test that checks for the existence of that specific html, then watching it fail, then writing the HTML.
If you think that's wrong, then 'test first' isn't always the 'right way'.
No, I'm not being facetious or sarcastic. Just pointing out that 'test first' isn't a requirement. It's an approach that has some good points. I 've done portions of some projects 'test first' and they generally turn, but it's not an approach I use exclusively 100% of the time.
"If you start by writing code you'll end up with the UI that was easiest to code rather than the UI that looks how the end user will want it to."
The problems with this thinking (which I mostly agree with, btw) is that not every project gets to involve checking with end users, nor do end users really understand what/how something should work until they're using something that actually allows a degree of interactivity. They may not even be aware of what's possible until they're poking around 'live'. While you might be reluctant to rejigger large portions of what you've done to move toward "easiest to code vs what they want/need", that's a different problem. It's a problem you need to be aware of, and ready to tackle when you cross it (and you'll know when because you're now aware of it).
- lmm 14y agoThe HTML you wrote isn't part of the live code, it's part of the test. It's perfectly normal to write some sort of skeleton/dummy as part of writing your tests - it's impossible to write a test without an interface to call into, after all.
- mgkimsal 14y ago" it's impossible to write a test without an interface to call into, after all" This is not at all what pure 'test first' has even been described as to me. You'd write a test - run it to watch it fail - then write the code to make the test pass. Whether that code is interface/ui/logic/whatever shouldn't make any difference. http://en.wikipedia.org/wiki/Test-driven_development#Test-driven_development_cycle http://en.wikipedia.org/wiki/Test-driven_development#Test-dr... "In test-driven development, each new feature begins with writing a test. This test must inevitably fail because it is written before the feature has been implemented." EDIT: "Test-driven development is difficult to use in situations where full functional tests are required to determine success or failure. Examples of these are user interfaces... " The TDD article on wikipedia is seeming to confirm that TDD for UI is hard (or is at least a shortcoming of a TDD approach).