user.perform("login",['user1','4321'],on(page))
assert page.successLogin,false
}
@Test
def should_login_success_with_exist_username_and_incorrect_password(){
LoginPage page = user.open(LoginPage,"/login.html")
user.perform("login",['user1','4321'],on(page))
assert page.successLogin,false
}
再运行一下测试,绿条。好啦,现在可以看下这段代码,恩,有些重复,重构一下:
Java代码
@Test
def should_login_success_with_exist_username_and_correct_password(){
assert login('user1','1234')
}
@Test
def should_login_success_with_exist_username_and_incorrect_password(){
assert login('user1','4321'),false
}
def login(username,password){
LoginPage page = user.open(LoginPage,"/login.html")
user.perform("login",[username,password],on(page))
return page.successLogin
文章来源于领测软件测试网 https://www.ltesting.net/