3 ms·
I think a common misconception about TDD is that it requires a a lot of overhead. It actually reduces overhead because you front-load the quality assurance, an
by Aqueous 13y ago
I think a common misconception about TDD is that it requires a a lot of overhead. It actually reduces overhead because you front-load the quality assurance, and save a lot of time going back and fixing bugs down the road. Some of the most popular open source projects use a lot of test coverage. Some very important projects don't, but I think the only reason Linux, for instance, has gotten away with this is because it has such a gigantic community that finds and fixes a bug immediately if one is found.
- pjmlp 13y agoHow do you TDD UI code?
- Aqueous 13y agoOn the web, you can use Selenium and pair it with either a headless browser like PhantomJS and/or a headless virtual machine running IE.
- pjmlp 13y agoHow you validate if the CSS or HTML is rendered as supposed to be?
- Aqueous 13y agoYou look at it :-) (Edit: That's not the whole answer. Usually when you test you assert that certain elements of the DOM are where they should be. At the very least you have verified the structure of the HTML document, if not how it looks. For actual aesthetics I can't see any way around human testing.)
- pjmlp 13y agoI am just playing devil's advocate. I work for Fortune 500 consulting projects and don't believe in TDD for UI code that works across the myriad of technologies we use in work projects, while scaling across multi-site development. TDD only seems to work on the business logic, and only in code written with testing in mind.
- quadhome 13y agoYou have the computer look at it. Brett Slatkin of Google Consumer Surveys has a great talk on using perceptual diffs for this: https://air.mozilla.org/continuous-delivery-at-google/ https://air.mozilla.org/continuous-delivery-at-google/
- sethrin 13y agoSo hopefully you have a way of generating HTML/CSS that will throw errors if you have incorrect or missing data. Beyond that, rendering a lot of things on one page is a good strategy. Among other benefits, it forces you to modularize your code in order to be able to do that. It's also a hell of a lot more efficient to look at one page with 50 items to check that they all rendered correctly, than it is to check 50 pages.
- zaphar 13y agoGreat! Now how do you TDD KDE UI code?
- sethrin 13y agoI am not entirely sure, but I think you GDB the STDOUT, grep the bin, and if that doesn't work, reroute the auxiliary phase array to the main deflectors. It works every time. I'm going to go out on a limb and say that if you write KDE UI code, you should be able to answer the question of how to test it, preferably in the automated sense. Notwithstanding all argument for and against TDD, the best proof of correctness is a long (manual) testing cycle.
- pjmlp 13y agoThe thing is, there is yet to exist any tool that allows TDD of desktop UIs beyond the toy examples people come up with web applications at conferences.
- lmm 13y agoThe same way. KDE components are very modular, so it's trivial to write a UI form that displays a bunch of components from various parts of your code. You could write a second executable that just displays this test form with test data (most of your code should be written as a library anyway, so having two executables that call your components shouldn't be an issue). Of course more automation is better, so I'd probably want to write a selenium-equivalent for asserting things about a component tree. Again, the KDE components are very regular so it's easy to generically traverse/inspect a GUI. It's really not hard if you actually try.