Hello guys, I'm new for testbox. I have a login cf...
# testing
j
Hello guys, I'm new for testbox. I have a login cfc and has the login function. Inside of the login function I have checked the login attempts. If the login attempts more than 3 times with wrong password then In the code we have used cfthrow like
if( loginAttempt > 3) {
cfthrow message="your account may be locked."
}
So, In the testbox side how can I able to achieve the expectations? Could you please help me?
a
You can use the the
toThrow
assertion. Something like:
Copy code
expect(function(){					  sut.myMethod();			}).toThrow("NoSuchChildException");
j
Yes. I tried like below, expect( function(){ userEdit.testLoginCredentials( email = variables.newUser.email, password = 'failedPassword' ); }).toThrow(); but getting the cfthrow message.
with error details
a
hmm, it should work. Might be worth doing a try / catch version instead. Something like:
Copy code
try {
  sut.myMethod();
  fail("should have errored");
} catch (any e) {
  expect(e.message).toBe("the message");  
}
It does sound like the error is maybe because the method is being called from another testcase though. Worth looking at the stack to see if you can trace it back.