Skip to content

Commit

Permalink
Document incremental capture option
Browse files Browse the repository at this point in the history
  • Loading branch information
tommysitu committed Jul 23, 2019
1 parent e7be008 commit 0d11337
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
18 changes: 18 additions & 0 deletions docs/pages/junit4/junit4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ Multi-Capture
File is relative to ``src/test/resources/hoverfly``.

.. _incrementalcapture:

Incremental Capture
-------------------

In capture mode, ``HoverflyRule`` by default exports the simulation and overwrites any existing content of the supplied file.
This is not very helpful if you add a new test and you don't want to re-capture everything.
In this case, you can enable the incremental capture option. ``HoverflyRule`` will check and import if the supplied simulation file exists. Any new request / response pairs will be appended to the existing file during capturing.

.. code-block:: java
@ClassRule
public static HoverflyRule hoverflyRule = HoverflyRule.inCaptureMode("simulation.json",
localConfigs()
.enableIncrementalCapture());
.. _captureorsimulate:

Capture or Simulate
Expand Down
23 changes: 7 additions & 16 deletions src/test/java/io/specto/hoverfly/ruletest/CaptureModeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
import io.specto.hoverfly.junit.core.model.Simulation;
import io.specto.hoverfly.junit.rule.HoverflyRule;
import io.specto.hoverfly.webserver.CaptureModeTestWebServer;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Set;
import org.json.JSONException;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.web.client.RestTemplate;

import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Set;

import static io.specto.hoverfly.junit.core.HoverflyConfig.localConfigs;
import static java.nio.charset.Charset.defaultCharset;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -70,13 +70,4 @@ public void shouldRecordInteractions() {
restTemplate.getForObject(webServerBaseUrl, String.class);
}


@Test
@Ignore("Currently Not Supported")
public void shouldRecordOtherInteractions() {
// When
restTemplate.getForObject(webServerBaseUrl.toString() + "/other", String.class);
}


}
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
package io.specto.hoverfly.ruletest;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources;
import io.specto.hoverfly.junit.core.model.RequestResponsePair;
import io.specto.hoverfly.junit.core.model.Simulation;
import io.specto.hoverfly.junit.rule.HoverflyRule;
import io.specto.hoverfly.webserver.CaptureModeTestWebServer;
import org.apache.commons.io.FileUtils;
import org.json.JSONException;
import org.junit.*;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.web.client.RestTemplate;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down

0 comments on commit 0d11337

Please sign in to comment.