# MockMvc

### Setup

{% hint style="info" %}
In order to use the MockMvc-extension it's required to have the [**skrapeit-core**](https://docs.skrape.it/docs/1.0.x/overview/setup#getting-super-powers) artifact in the classpath as well as having a proper spring-test / spring-boot-test setup.
{% endhint %}

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

```markup
<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 %}
{% endtab %}

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

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

{% endcode %}
{% endtab %}
{% endtabs %}

### How to Use

The [**skrape{it}**](https://docs.skrape.it/docs/1.0.x/master) **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.&#x20;

![Documentation by example](https://1047591382-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWL7T2s3Imnrv94gbbk%2F-LckiS6gjy9QRawyDDxo%2F-Lckici0u9DRUXDwG-pj%2Fexample-usage.gif?alt=media\&token=76f6b219-9ead-4234-b9d5-466160c967b3)
