繁体   English   中英

如何从代码中运行gatling

[英]How to run gatling from code

我想从代码中运行Gatling测试。 怎么做? 教程只说命令行和sbt。

上下文:我想扩展测试。 在后台我有自定义套接字通信,我需要模拟。 从模拟中我需要将一些生成的ID传递给Gatling测试。 我可以通过我的模拟应用程序使用参数运行它(但我还不知道如何)。 其他解决方案也是一个很好的答案。

我可以做一些传递文件和http://gatling.io/docs/2.1.6/cookbook/passing_parameters.html ,但它很丑..

也许有办法从scala代码运行sbt任务?

import io.gatling.app.Gatling
import io.gatling.core.config.GatlingPropertiesBuilder

object Engine extends App {

  val props = new GatlingPropertiesBuilder
  props.simulationClass("your.simulation.class.goes.here")
  props.dataDirectory("path.to.data.directory") //optional
  props.resultsDirectory("path.to.results.directory") //optional
  props.bodiesDirectory("path.to.template.directory") //optional
  props.binariesDirectory("path.to.binaries.directory") //optional

  Gatling.fromMap(props.build)
}

希望这会有所帮助。

我同意Gatling网站上的文档没有解释得那么好(我前几天找了)但是Gatling提供了一个很好的示例,其中包含一些如何实现这一目标的文档:

https://github.com/gatling/gatling-sbt-plugin-demo

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM