• 1.8.0

W3C Hamcrest Matchers

W3CMatchers is a utility class with static methods that create W3C Hamcrest matchers, to be used in unit tests, for example:

import com.jcabi.matchers.W3CMatchers;
import org.hamcrest.MatcherAssert;
public class FooTest {
  @Test
  public void htmlIsValidAccordingToW3C() {
    MatcherAssert.assertThat(
      "<html><body>Hello</body></html>",
      W3CMatchers.validHtml()
    );
  }
}

The same for CSS:

import com.jcabi.matchers.W3CMatchers;
import org.hamcrest.MatcherAssert;
public class FooTest {
  @Test
  public void htmlIsValidAccordingToW3C() {
    MatcherAssert.assertThat(
      "body { color: red; }",
      W3CMatchers.validCss()
    );
  }
}

These dependencies you will need in your pom.xml:

<dependency>
  <groupId>org.hamcrest</groupId>
  <artifactId>hamcrest-library</artifactId>
  <version>1.3</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.hamcrest</groupId>
  <artifactId>hamcrest-core</artifactId>
  <version>1.3</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.jcabi</groupId>
  <artifactId>jcabi-w3c</artifactId>
  <version>1.0</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.jcabi</groupId>
  <artifactId>jcabi-w3c</artifactId>
  <version>1.0</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.glassfish</groupId>
  <artifactId>javax.json</artifactId>
  <version>1.0.4</version>
  <scope>test</scope>
</dependency>