我正在与gatling合作,并收到此错误,该错误声称“notstartedrefids”已定义。我是加特林的新手,我相信这个价值已经被正确地宣布了,但是我不明白为什么它没有被承认。
包含对值的引用的代码如下:
case object StudentAssignmentScenario {
private val notStartedRefIdsSession = "notStartedRefIds"
private val studentAssignmentRefIdSession = "studentAssignmentRefId"
private val endpoint: String = environmentAssignmentsUrls + "/v2/studentAssignments"
private val startAssignment = http("Start StudentAssignment")
.put(endpoint + "/${studentAssignmentRefId}/start")
.headers(getHeaderMap)
.check(status.is(200))
private val submitAssignment = http("Submit StudentAssignment")
.put(endpoint + "/${studentAssignmentRefId}/submit")
.headers(getHeaderMap)
.check(status.is(200))
private val startAndSubmitAssignments = exec { session =>
val refId = session(notStartedRefIdsSession).as[Seq[String]].apply(0)
session.set(studentAssignmentRefIdSession, refId)
}.exec(startAssignment).exec(submitAssignment)
private val startAssignments = exec { session =>
val refId = session(notStartedRefIdsSession).as[Seq[String]].apply(1)
session.set(studentAssignmentRefIdSession, refId)
}.exec(startAssignment)
def readStudentAssignments = exec(http("Get Not Started StudentAssignments")
.get(endpoint)
.headers(getHeaderMap)
.queryParamMap(Map[String, String]("inclExpired" -> "true",
"context" -> "basel",
"sort" -> "dueDate,title",
"limit" -> "25", "offset" -> "0",
"status" -> "NOT_STARTED"))
.check(status.is(200),
// save refIds
jsonPath("$.items[?(@.status == 'NOT_STARTED')].refId").findAll.optional.saveAs("notStartedRefIds")))
private val studentAssignmentWorkflow = exec(startAndSubmitAssignments)
.exec(startAssignments)
val studentAssignmentWorkflowSetup: ChainBuilder = exitBlockOnFail(
group("Student Assignment Workflow") {
studentAssignmentWorkflow
})
}
1条答案
按热度按时间pbossiut1#
你似乎唯一居住的地方
notStartedRefIds
在readStudentAssignments
在那里你从一个jsonPath
.但是,您已将此检查配置为
optional
意味着你希望它有时不在这里。如果是这样的话,那么在调用时它可以是未定义的也就不足为奇了session(notStartedRefIdsSession)
.