Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (45 sloc) 1.51 KB
description
An Extension for Spring MockMvc tests to enable meaningful testing of controllers that produces HTML.

MockMvc

Setup

{% hint style="info" %} In order to use the MockMvc-extension it's required to have the skrapeit-core artifact in the classpath as well as having a proper spring-test / spring-boot-test setup. {% endhint %}

{% tabs %} {% tab title="Maven" %} {% code-tabs %} {% code-tabs-item title="pom.xml" %}

<dependency>
   <groupId>it.skrape</groupId>
   <artifactId>skrapeit-core</artifactId>
   <version>LATEST</version>
   <scope>test</scope>
</dependency>
<dependency>
   <groupId>it.skrape</groupId>
   <artifactId>skrapeit-mockmvc</artifactId>
   <version>LATEST</version>
   <scope>test</scope>
</dependency>

{% endcode-tabs-item %} {% endcode-tabs %} {% endtab %}

{% tab title="Gradle" %} {% code-tabs %} {% code-tabs-item title="build.gradle.kts" %}

testCompile("it.skrape:skrapeit-core:+")
testCompile("it.skrape:skrapeit-mockmvc:+")

{% endcode-tabs-item %} {% endcode-tabs %} {% endtab %} {% endtabs %}

How to Use

The skrape{it} MockMvc-extension will extend MockMvc's ResultActions with an andExpectHtml{} lambda function. The scope of the lambda will give you a parsed response body (deserialized to a Doc) and enables you to make comfortable assumptions about the content, properties and structure of the document.

Documentation by example

You can’t perform that action at this time.