Browse Source

Refactoring: Optimized Structure of Tests

feature-pr/user
Maxim Volkov 3 years ago
parent
commit
866807f244
  1. 19
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java

19
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java

@ -26,10 +26,10 @@ public class CustomersTest extends TestCase {
customers.registerUser(userToRegister);
// When
boolean nicknameIsTaken = !customers.nickNameAvailable(availableNickname);
boolean nicknameIsTaken = customers.nickNameAvailable(availableNickname);
// Then
assertTrue(nicknameIsTaken);
assertFalse(nicknameIsTaken);
}
public void test_registerSingleUser() {
@ -43,7 +43,8 @@ public class CustomersTest extends TestCase {
// Get the expected User
User expectedUser = customers.getByNickname(expectedNickNameInput);
assertTrue(null != expectedNewUser);
//
assertNotNull(expectedNewUser);
String expectedNickNameGotBack = expectedUser.nickName;
// When
@ -78,7 +79,7 @@ public class CustomersTest extends TestCase {
for (int i = 0; i < expectedNickNamesInput.length; i++) {
// Get user
foundUser = customers.getByNickname(expectedNickNamesInput[i]);
assertTrue(null != foundUser);
assertNotNull(foundUser);
// When
expectedNickNameGotBack = foundUser.nickName;
@ -97,8 +98,8 @@ public class CustomersTest extends TestCase {
customers.registerUser(userToRegister);
// When
boolean userExists = !customers.nickNameAvailable(userToRemove);
assertTrue(userExists);
boolean userExists = customers.nickNameAvailable(userToRemove);
assertFalse(userExists);
// Then
User removedUser = customers.deleteUser(userToRemove);
@ -139,11 +140,7 @@ public class CustomersTest extends TestCase {
User gotUser = customers.getByNickname(nickName);
// When
boolean foundUser = null != gotUser;
// Then
assertTrue(foundUser);
assertNotNull(gotUser);
// When
boolean correctFirstName = "Mia".equals(gotUser.getFirstName());

Loading…
Cancel
Save