# Mock requests in transaction

**URL:** https://community.gatling.io/t/mock-requests-in-transaction/9348
**Category:** Gatling (Open-Source)
**Created:** [October 9, 2024, 11:56am UTC](https://community.gatling.io/t/mock-requests-in-transaction/9348 "2024-10-09T11:56:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![i-nahornyi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/i-nahornyi/32/1658_2.png) [@i-nahornyi](https://community.gatling.io/u/i-nahornyi)
#### Post date: [October 9, 2024, 11:56am UTC](https://community.gatling.io/t/mock-requests-in-transaction/9348/1 "2024-10-09T11:56:26Z")

</div>

**Gatling version** : 3.12.0 (must be up to date)  
**Gatling flavor** : java kotlin scala javascript typescript  
**Gatling build tool** : maven gradle sbt bundle npm

I read the [guidelines](https://community.gatling.io/t/welcome-in-the-gatling-community-our-code-of-conduct/6462) and [how to ask a question](https://community.gatling.io/t/how-to-ask-a-question/6538) topics.  
 I provided a [SSCCE](http://www.sscce.org/) (or at least, all information to help the community understand my topic)  
 I copied output I observe, and explain what I think should be.

Hello Gatling Community,

I’m facing an issue where I need to **mock (not actually perform)** a specific request within a transaction, while still **including its time in the total transaction duration calculation**.

A real-world example would be a third-party request that incurs a cost, but where I already know the range of its response times.

In JMeter, we have something like the [Dummy Sampler](https://jmeter-plugins.org/wiki/DummySampler/), which allows for this kind of functionality.

Is there a simple way to achieve this in Gatling?

I created a workaround that works for me (see the example [here](https://gist.github.com/i-nahornyi/8a9a05bdeaa416355ba470d5464fd346#file-simulationwithmock-java)),  
but I don’t really want to reinvent the wheel if Gatling already has this feature.  
So maybe I missed something?

From my perspective, it looks like all I need is `statsEngine.logResponse()`.

Thanks!

---

<div class="post-metadata">

### Author: ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)
#### Post date: [October 9, 2024, 11:59am UTC](https://community.gatling.io/t/mock-requests-in-transaction/9348/2 "2024-10-09T11:59:58Z")

</div>

A simple `pause` would do the work and its duration would be included in the group duration metric.

---

<div class="post-metadata">

### Author: ![i-nahornyi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/i-nahornyi/32/1658_2.png) [@i-nahornyi](https://community.gatling.io/u/i-nahornyi)
#### Post date: [October 9, 2024, 12:29pm UTC](https://community.gatling.io/t/mock-requests-in-transaction/9348/3 "2024-10-09T12:29:44Z")

</div>

Is there a workaround available if I prefer to use `CumulatedResponseTime` instead of `GroupDuration`?  
I apologize for not noticing this in the original topic.

I plan to use pauses between requests.

---

<div class="post-metadata">

### Author: ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)
#### Post date: [October 9, 2024, 12:38pm UTC](https://community.gatling.io/t/mock-requests-in-transaction/9348/4 "2024-10-09T12:38:54Z")

</div>

CumulatedResponseTime only accounts for real traffic time so no, it wouldn’t work.

This is the first time we ever have this feature request so we won’t work on this unless there’s enough demand.

I’m looking for workarounds. The only ones I can think of are:

- pause + GroupDuration
- deploy a mock app with controlled response time (there are plenty of these out there)

---

<div class="post-metadata">

### Author: ![wowkai](https://avatars.discourse-cdn.com/v4/letter/w/46a35a/32.png) [@wowkai](https://community.gatling.io/u/wowkai)
#### Post date: [October 14, 2024, 3:47am UTC](https://community.gatling.io/t/mock-requests-in-transaction/9348/5 "2024-10-14T03:47:44Z")

</div>

Hi @i-nahornyi.  
If you want save this mock transaction (it could be pause, random code block, etc) to report, try to use this plugin: [GitHub - polarnik/gatling-asynclog-plugin: Flexible log writer for Gatling 3](https://github.com/polarnik/gatling-asynclog-plugin). Here examle of the simulation [GitHub - polarnik/gatling-asynclog-plugin: Flexible log writer for Gatling 3](https://github.com/polarnik/gatling-asynclog-plugin).

---

<div class="post-metadata">

### Author: ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)
#### Post date: [November 13, 2024, 3:48am UTC](https://community.gatling.io/t/mock-requests-in-transaction/9348/6 "2024-11-13T03:48:07Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
