My primary reason against Tests for CSS, is that CSS is not about business logic. And the other being that the way CSS works is the last run CSS styling over-rides the previous one. Unit-testing eh? The order of CSS styling that is applied depends on the order of inclusion, correct? Now write anaother test for this? All these thoughts, made me laugh at the idea of Testing the CSS back then. All said, I was still curious to know what was the positive/negative experience of those who tried it.
How would you even "test" CSS?<p>Look for particular expectations being met in the browser?<p>As a lot of the general TDD stuff I'd say it's a bad idea.<p>It gives you nothing extra of value.<p>Instead you end up multiplying the number of times you declare/define/write something.<p>I consider this kind of stuff feel good busy work. You want to brag about your CSS test coverage (?!) but you are just wasting time and picking up complexity.<p>Tests at this level of granularity are just not worth it.<p>What's next TDD your TDD?
IMO CSS doesn't really need unit tests because you are QA-ing it as you develop it. You can't really write CSS without looking at the page and making sure it looks good. If you're already looking at the page to make sure it looks good, what's the point of writing tests to do the same thing?
I've found testing tools that take screenshots very useful. Once you're happy with the site, you take screenshots at various screen widths and after you make changes you can view visual diffs of the new screenshots to see if you broke anything.