Validation, meet Unit Testing. Unit Testing, meet Validation.
By Anders Pearson | September 20th, 2005 | Filed in Validation
Skip to comment formAre you “test infected“? Do you work on dynamic sites and wish there was an automated way to run the output through the W3C validator? Do you wish it was integrated nicely with your unit testing framework?
Scott Raymond has come up with a nice bit of code to add automated validation to the unit tests for a Ruby on Rails application.
If you’re not on Rails, the technique should be pretty straightforward to adapt to your prefered language/framework. Just make a POST
request to http://validator.w3.org/check
sending parameters fragment
(your page, encoded) and output=xml
. Then check the response for a header called x-w3c-validator-status
to see if it says Valid
. If so, your test passed.
This entry cross-posted to take your comments.