Did not write csv file

When the test result is successful, was written resp to the CSV file
When getting the Connection time-out error was not written resp to the CSV file

How can I do this?

val scn = scenario("load test")

    .exec(session => {
      if (session("code").as[String].contains("1000") && session("message").as[String].contains("Success")) {
        response_writer2.println("code = " + session("code").as[String] + ",id = " + session("id").as[String] + ",message = " + session("message").as[String] + ",retult = Passed")
      } else {
        response_writer2.println("code = " + session("code").as[String] + ",id = " + session("id").as[String] + ",message = " + session("message").as[String] + ",retult = Failed")

Hi @Ehtimad,

I’m not sure to understand your question.

I assume you want a way to write in your response_writer or response_writer2 only when the previous request didn’t fail. Am I correct?

In that case, you can use a condition statement based on session state

Or if you don’t need to do anything with that virtual user anymore: exitHereIfFailed before the writing exec.


I want to write every request

For example
I write
if code =1000 result=success else result=Failed
Written to the CSV file as this
code = 1000,id = 790726e615ed,message = Success,result = Passed
code = 1000,id = 790726e615ed,message = Success,result = Failed

When I run the test and when I get the “Connection time-out” error
Written nothing

I want to write a response to the CSV file.
“Connection time-out”

How do I do it?