# Modularising /chaining scenarios

**URL:** <https://community.gatling.io/t/modularising-chaining-scenarios/5253>\
**Category:** Gatling (Open-Source)\
**Created:** [September 23, 2019, 11:34am UTC](https://community.gatling.io/t/modularising-chaining-scenarios/5253 "2019-09-23T11:34:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shazad\_Dad](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@Shazad\_Dad](https://community.gatling.io/u/Shazad_Dad)\
**Post date:** [September 23, 2019, 11:34am UTC](https://community.gatling.io/t/modularising-chaining-scenarios/5253/1 "2019-09-23T11:34:12Z")

</div>

Hi

I have tried to implement a process running scenarios in sequence using the method described in :[https://stackoverflow.com/questions/15568284/modularising-scenarios-to-run-in-sequence-using-gatling](https://stackoverflow.com/questions/15568284/modularising-scenarios-to-run-in-sequence-using-gatling)

We have a number of scenarios that will be running in parallel, but there are a few that will need to be run in sequence, i.e scn1, then scn2 then scn3

ive tried this

package CommPayPerfTest

import CommPayPerfTest.Configuration.\_  
import CommPayPerfTest.Components.Common.\_  
import CommPayPerfTest.Scenarios.\_  
import CommPayPerfTest.Scenarios.CommPay.PerfTestApi.\_  
import io.gatling.core.structure.{ChainBuilder, ScenarioBuilder}

import io.gatling.core.Predef.\_  
import io.gatling.http.Predef.\_  
import scala.concurrent.duration.\_

// Use this for developing a scenario in isolation  
class StatementSimulation extends Simulation {

val httpProtocol = Config.getHttpProtocol(http)

val statementRecords = exec(StatementRecord)  
val statementImport = exec(StatementImport)

val modular = Seq (statementRecords,statementImport)

val scn1 = scenario (“Scenario 1”).exec(modular)

setUp(

scn1.getScenario()  
.inject(atOnceUsers(1))

[//scn1.getScenario](https://scn1.getScenario)()  
// .inject(atOnceUsers(1))  
)

.protocols(httpProtocol)

}

but it fails with this error:

12:13:14.968 [ERROR] i.g.c.ZincCompiler$ - C:\Gatling\Commpay-PerformanceTesting\user-files\simulations\CommPayPerfTest\Scenarios\CommPay\PerfTestApi\StatementScenarios.scala:20:28: overloaded method value exec with alternatives:  
(scenario: io.gatling.core.structure.ScenarioBuilder)io.gatling.core.structure.ChainBuilder   
(chains: Iterable[io.gatling.core.structure.ChainBuilder])io.gatling.core.structure.ChainBuilder   
(chains: Iterator[io.gatling.core.structure.ChainBuilder])io.gatling.core.structure.ChainBuilder   
(chains: io.gatling.core.structure.ChainBuilder\*)io.gatling.core.structure.ChainBuilder   
(actionBuilder: io.gatling.core.action.builder.ActionBuilder)io.gatling.core.structure.ChainBuilder   
(sessionFunction: io.gatling.core.session.Expression[io.gatling.core.session.Session])io.gatling.core.structure.ChainBuilder  
cannot be applied to (CommPayPerfTest.Scenarios.CommPay.PerfTestApi.StatementRecord.type)  
val statementRecords = exec(StatementRecord)

any ideas i thought this would be straightforward…)  
^

[![iress.com](https://www.iress.com/media/images/iress-logo-email-signature.original.png "iress.com")](https://www.iress.com/)

Shazad Dad​

Senior Tester

Tel: +441926621417

[**shazad.dad@iress.com**](mailto:shazad.dad@iress.com)

[**www.iress.com**](https://www.iress.com/)

1 Kingmaker Court, Warwick Technology Park, Gallows Hill,  
Warwick, Warwickshire, CV34 6DY

The contents of this email originated from Iress. For this purpose Iress includes Iress Limited and/or any of its subsidiaries, holding companies and trading entities.  
​If you have received this email in error please notify the sender immediately and delete this email.

nosig

---

<div class="post-metadata">

**Author:** ![notdryft](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/notdryft/32/1103_2.png) [@notdryft](https://community.gatling.io/u/notdryft)\
**Post date:** [September 23, 2019, 11:53am UTC](https://community.gatling.io/t/modularising-chaining-scenarios/5253/2 "2019-09-23T11:53:24Z")

</div>

Hi,

It says “cannot be applied to (CommPayPerfTest.Scenarios.CommPay.PerfTestApi.StatementRecord.type)”. Hence, I suspect StatementRecord and StatementImport are actually objects while they should be vals of defs with a chain inside.

---

<div class="post-metadata">

**Author:** ![Shazad\_Dad](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@Shazad\_Dad](https://community.gatling.io/u/Shazad_Dad)\
**Post date:** [September 23, 2019, 12:49pm UTC](https://community.gatling.io/t/modularising-chaining-scenarios/5253/3 "2019-09-23T12:49:10Z")

</div>

thank you for your response,  
i changed the simulation so it calls the object and then then defs like

val statementRecords = exec(StatementRecord.createStatementRecord)  
val statementImport = exec(StatementImport.importStatements)

val modular = Seq (statementRecords,statementImport)

val scn1 = scenario (“Scenario 1”).exec(modular)

setUp(

scn1.inject(  
atOnceUsers(1))

[//scn1.getScenario](https://scn1.getScenario)()  
// .inject(atOnceUsers(1))  
)

.protocols(httpProtocol)

it compiles which is better news, but it only runs the second scenario ‘Statement Import’ - not the first one statementrecords.?

![](https://www.iress.com/media/images/iress-logo-email-signature.original.png)

Shazad Dad​

Senior Tester

Tel: +441926621417

The contents of this email originated from Iress. For this purpose Iress includes Iress Limited and/or any of its subsidiaries, holding companies and trading entities.  
​​If you have received this email in error please notify the sender immediately and delete this email.

---

<div class="post-metadata">

**Author:** ![Shazad\_Dad](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@Shazad\_Dad](https://community.gatling.io/u/Shazad_Dad)\
**Post date:** [September 23, 2019, 1:44pm UTC](https://community.gatling.io/t/modularising-chaining-scenarios/5253/4 "2019-09-23T13:44:44Z")

</div>

Thats now working thanks

![](https://www.iress.com/media/images/iress-logo-email-signature.original.png)

Shazad Dad​

Senior Tester

Tel: +441926621417

The contents of this email originated from Iress. For this purpose Iress includes Iress Limited and/or any of its subsidiaries, holding companies and trading entities.  
​​If you have received this email in error please notify the sender immediately and delete this email.

---

<div class="post-metadata">

**Author:** ![Shazad\_Dad](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@Shazad\_Dad](https://community.gatling.io/u/Shazad_Dad)\
**Post date:** [September 23, 2019, 2:46pm UTC](https://community.gatling.io/t/modularising-chaining-scenarios/5253/5 "2019-09-23T14:46:42Z")

</div>

just an additional question related to this, when creating a sequence of scenarios can i still use the individual scenario set in the simulation or would it need to use a single generic feeder file?

![](https://www.iress.com/media/images/iress-logo-email-signature.original.png)

Shazad Dad​

Senior Tester

Tel: +441926621417

The contents of this email originated from Iress. For this purpose Iress includes Iress Limited and/or any of its subsidiaries, holding companies and trading entities.  
​​If you have received this email in error please notify the sender immediately and delete this email.
