jsoup Hamcrest Matchers

Hamcrest matchers to support the use of Jsoup in tests.

Лицензия

Лицензия

Категории

Категории

Сеть jsoup Прикладные библиотеки
Группа

Группа

net.oneandone.jsoup
Идентификатор

Идентификатор

jsoup-hamcrest
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

jsoup Hamcrest Matchers
Hamcrest matchers to support the use of Jsoup in tests.
Ссылка на сайт

Ссылка на сайт

https://github.com/1and1/jsoup-hamcrest
Организация-разработчик

Организация-разработчик

1&1
Система контроля версий

Система контроля версий

https://github.com/1and1/jsoup-hamcrest/

Скачать jsoup-hamcrest

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/net.oneandone.jsoup/jsoup-hamcrest/ -->
<dependency>
    <groupId>net.oneandone.jsoup</groupId>
    <artifactId>jsoup-hamcrest</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.oneandone.jsoup/jsoup-hamcrest/
implementation 'net.oneandone.jsoup:jsoup-hamcrest:1.0.0'
// https://jarcasting.com/artifacts/net.oneandone.jsoup/jsoup-hamcrest/
implementation ("net.oneandone.jsoup:jsoup-hamcrest:1.0.0")
'net.oneandone.jsoup:jsoup-hamcrest:jar:1.0.0'
<dependency org="net.oneandone.jsoup" name="jsoup-hamcrest" rev="1.0.0">
  <artifact name="jsoup-hamcrest" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.oneandone.jsoup', module='jsoup-hamcrest', version='1.0.0')
)
libraryDependencies += "net.oneandone.jsoup" % "jsoup-hamcrest" % "1.0.0"
[net.oneandone.jsoup/jsoup-hamcrest "1.0.0"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
org.jsoup : jsoup jar 1.12.1
org.hamcrest : hamcrest-core jar 2.2
org.hamcrest : hamcrest-library jar 2.2

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.
jsoup hamcrest
jsoup hamcrest
jsoup hamcrest

JSoup Hamcrest Matchers

jsoup-hamcrest brings the power of css matchers to your tests.

Maven

<dependencies>
    <dependency>
        <groupId>net.oneandone.jsoup</groupId>
        <artifactId>jsoup-hamcrest</artifactId>
        <version>1.0.0</version>
        <scope>test</scope>
    </dependency>
</dependencies>

You can check the latest version here.

Usage

jsoup-hamcrest uses a fluent api design to create your assertions, while still offering the comparability of Hamcrest matchers.

import static net.oneandone.jsoup.hamcrest.fluent.DocumentAssertions.anElement;  // (1)
import static net.oneandone.jsoup.hamcrest.fluent.JsoupAssertions.html;          // (1)

html(source)                                                  // (2)
    .expect(anElement("#exampleInputEmail")                   // (3)
        .hasAttribute("placeholder")                          // (4)
        .hasAttribute("placeholder", "Email")                 // (5)
        .hasAttribute("placeholder", equalTo("Email")));      // (6)
  1. static import of factory methods for better readability (optional)

  2. create an instance of JsoupAssertions using html factory method

  3. create an expectation, you can create multiple expectations for a document by chaining expect or its alias and. anElement creates a matcher for a single element with the given css query. (There is also eachElement and elements for performing assertions on each element or on the collection of found elements respectively)

  4. hasAttribute asserts the existence of the placeholder attribute on the element

  5. hasAttribute asserts that the value of the placeholder attribute is Email

  6. hasAttribute asserts that the value of the placeholder attribute is Email using a hamcrest matcher, you could also use containsString for example.

For more examples take a look at the AllMatcherHappyTest or FluentExampleTest to see usage examples.

net.oneandone.jsoup

1&1

Open Source by 1&1 Group.

Версии библиотеки

Версия
1.0.0