问题描述
我在加特林机上编写测试,然后尝试将socket.io事件发送到服务器。但是在构建项目时会出错。
错误
/home/pbezpal/roschat/testing-roschat/load-testing/Gatling/src/test/scala/ServerLoad.scala:49:17
type mismatch;
found : io.socket.emitter.Emitter
required: io.gatling.commons.validation.Validation[io.gatling.core.session.Session]
socket.on( Socket.EVENT_CONNECT,new Listener {
如何正确书写。谢谢
解决方法
我设法做到了
.exec(session => {
val obj = new JSONObject()
val aknowledge = null
obj.put("login","${login}")
obj.put("password","${password}")
obj.put("APILevel","${level}")
optConnect.forceNew = false
optConnect.timeout = 10000
val socket = IO.socket( socketUrl,optConnect )
val printListener: Emitter.Listener = new Emitter.Listener {
override def call(args: AnyRef*): Unit = {
}
}
socket.on(Socket.EVENT_CONNECT,printListener)
socket.connect()
socket.emit("login",obj)
session
}
)
但是现在$ {login}被发送到服务器,而不是csv文件中的值。如何解决?谢谢