Class LoginServiceNGTest
java.lang.Object
jmockit.loginExample.domain.userLogin.LoginServiceNGTest
A small TestNG test suite for a single class (
LoginService
), based on
this article.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Disallow concurrent logins.void
Disallow logging into revoked account.void
Not revoke second account after two failed attempts on first account.void
This test is also redundant, as it exercises the same path as the previous one.void
Reset back to initial state after successful login.void
This test is redundant, as it exercises the same path as the last test.void
Sets the account to revoked after three failed login attempts.void
Throw exception if account not found.
-
Constructor Details
-
LoginServiceNGTest
public LoginServiceNGTest()
-
-
Method Details
-
setAccountToLoggedInWhenPasswordMatches
This test is redundant, as it exercises the same path as the last test. It cannot simply be removed, because the last test does not perform the "account.setLoggedIn(true)" verification; if said verification is added there, however, then this test could be removed without weakening the test suite.- Throws:
Exception
- the exception
-
setAccountToRevokedAfterThreeFailedLoginAttempts
Sets the account to revoked after three failed login attempts.- Throws:
Exception
- the exception
-
notSetAccountLoggedInIfPasswordDoesNotMatch
This test is also redundant, as it exercises the same path as the previous one. Again, it cannot simply be removed since the previous test does not verify that "account.setLoggedIn(true)" is never called; if said verification is added there, however, this test could safely be removed.- Throws:
Exception
- the exception
-
notRevokeSecondAccountAfterTwoFailedAttemptsOnFirstAccount
Not revoke second account after two failed attempts on first account.- Throws:
Exception
- the exception
-
disallowConcurrentLogins
public void disallowConcurrentLogins()Disallow concurrent logins. -
throwExceptionIfAccountNotFound
public void throwExceptionIfAccountNotFound()Throw exception if account not found. -
disallowLoggingIntoRevokedAccount
public void disallowLoggingIntoRevokedAccount()Disallow logging into revoked account. -
resetBackToInitialStateAfterSuccessfulLogin
Reset back to initial state after successful login.- Throws:
Exception
- the exception
-