### Question:
LabelForTextareaRule extends AbstractRule { @Override protected void applyTo(Page page, Violations violations) { for (HtmlTextArea textarea : page.findAllTextareaTags()) { if (hasNonEmptyAttribute(textarea, "id") && !containsLabelForId(page.findAllLabelTags(), textarea.getId())) { violations.add(createViolation(textarea, page, RULE_MESSAGE)); } } }  @Override String getName();  }### Answer:
@Test public void textareaWithAssociatedLabel() throws Exception { String content = "<html><body><form><label for=\"comment\">Comment</label><textarea id=\"comment\"></textarea></form></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertNoViolations(violations); }
@Test public void textareaWithMissingLabel() throws Exception { String content = "<html><body><form><textarea id=\"firstname\"></textarea></form></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 1); }