【发布时间】:2016-01-22 03:22:54
【问题描述】:
我是 gatling 的新用户,我想测试一个 Web 应用程序的登录场景。我遇到了以下问题,我用错误的密码编写了 scala 脚本来测试登录场景,但我发现最终结果不是我预期的失败,发生了什么问题?
我的 scala 程序:
package cnblogsCase
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class MueasSimulation extends Simulation{
val httpConf = http.baseURL("http://localhost:8080")
var scn = scenario("Search mueas home page")
.exec(http("Redirect Login").get("/").check(currentLocation.saveAs("post_url")))
.pause(10 seconds)
.exec(http("Try login").post("${post_url}")
.formParam("username", "shihuc")
.formParam("password", "123456").check(status.is(200)))
.pause(10 seconds)
setUp(scn.inject(atOnceUsers(2)).protocols(httpConf))
}
而且,我的 Web 应用程序中登录的表单部分是这样的:
<form method="post" action="/login">
<input type="text" required="required" name="username" placeholder="ID or Email-address">
<input type="password" required="required" name="password" placeholder="Password">
<div class="remfog">
<div class="rem">
<label>
<input type="checkbox" name="remember-me" value="true" style="margin-top:10px">
Remember Me
</label>
</div>
<div class="fog">
<a title="Reset password" href="/password/forgot">Forgot Password?</a>
</div>
</div>
<input class="csubmit" type="submit" value="Log in">
</form>
我的预期结果是失败,因为scala脚本中的用户名和密码不正确,但实际上是可以的,不是KO。请检查log 文件。我的加特林版本是 2.1.7。
【问题讨论】:
-
当您提供不正确的凭据时,您真的可以确认您正在测试的 web 应用程序返回的不是“200 OK”吗?并非每个 web 应用程序都是 RESTful 无处不在...
-
感谢您的反馈!在这里,我确定我的 web APP 是 RESTful 的。