Skip to content

Commit 86faec5

Browse files
committed
bank-account: add ignore hint and improve HINTS.md
1 parent b9e3d3d commit 86faec5

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

‎exercises/bank-account/HINTS.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ To pass the last test you might find the
44

55
Problems arising from running code concurrently are often intermittent because they depend on the order the code is
66
executed. Therefore the last test runs many [threads](https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html)
7-
several times to increase the chances of catching a bug.
7+
several times to increase the chances of catching a bug. That means this test should fail if your implementation is not
8+
[thread safe](https://en.wikipedia.org/wiki/Thread_safety), but there is a chance it will pass just because there was
9+
no concurrent modification attempt. It is unlikely that this will occur several times
10+
in a row since the order the code is executed should vary every time you run the test. So if you run the last test a
11+
couple of times and it passes every time then you can be reasonably sure that your implementation is correct.

‎exercises/bank-account/src/test/java/BankAccountTest.java‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void newlyOpenedAccountHasEmptyBalance() throws BankAccountActionInvalidE
2626
assertEquals(0, bankAccount.getBalance());
2727
}
2828

29-
@Ignore
29+
@Ignore("Remove to run test")
3030
@Test
3131
public void canDepositMoney() throws BankAccountActionInvalidException {
3232
bankAccount.open();
@@ -36,7 +36,7 @@ public void canDepositMoney() throws BankAccountActionInvalidException {
3636
assertEquals(10, bankAccount.getBalance());
3737
}
3838

39-
@Ignore
39+
@Ignore("Remove to run test")
4040
@Test
4141
public void canDepositMoneySequentially() throws BankAccountActionInvalidException {
4242
bankAccount.open();
@@ -47,7 +47,7 @@ public void canDepositMoneySequentially() throws BankAccountActionInvalidExcepti
4747
assertEquals(28, bankAccount.getBalance());
4848
}
4949

50-
@Ignore
50+
@Ignore("Remove to run test")
5151
@Test
5252
public void canWithdrawMoney() throws BankAccountActionInvalidException {
5353
bankAccount.open();
@@ -58,7 +58,7 @@ public void canWithdrawMoney() throws BankAccountActionInvalidException {
5858
assertEquals(5, bankAccount.getBalance());
5959
}
6060

61-
@Ignore
61+
@Ignore("Remove to run test")
6262
@Test
6363
public void canWithdrawMoneySequentially() throws BankAccountActionInvalidException {
6464
bankAccount.open();
@@ -70,7 +70,7 @@ public void canWithdrawMoneySequentially() throws BankAccountActionInvalidExcept
7070
assertEquals(0, bankAccount.getBalance());
7171
}
7272

73-
@Ignore
73+
@Ignore("Remove to run test")
7474
@Test
7575
public void cannotWithdrawMoneyFromEmptyAccount() throws BankAccountActionInvalidException {
7676
bankAccount.open();
@@ -81,7 +81,7 @@ public void cannotWithdrawMoneyFromEmptyAccount() throws BankAccountActionInvali
8181
bankAccount.withdraw(5);
8282
}
8383

84-
@Ignore
84+
@Ignore("Remove to run test")
8585
@Test
8686
public void cannotWithdrawMoreMoneyThanYouHave() throws BankAccountActionInvalidException {
8787
bankAccount.open();
@@ -93,7 +93,7 @@ public void cannotWithdrawMoreMoneyThanYouHave() throws BankAccountActionInvalid
9393
bankAccount.withdraw(7);
9494
}
9595

96-
@Ignore
96+
@Ignore("Remove to run test")
9797
@Test
9898
public void cannotDepositNegativeAmount() throws BankAccountActionInvalidException {
9999
bankAccount.open();
@@ -104,7 +104,7 @@ public void cannotDepositNegativeAmount() throws BankAccountActionInvalidExcepti
104104
bankAccount.deposit(-1);
105105
}
106106

107-
@Ignore
107+
@Ignore("Remove to run test")
108108
@Test
109109
public void cannotWithdrawNegativeAmount() throws BankAccountActionInvalidException {
110110
bankAccount.open();
@@ -116,7 +116,7 @@ public void cannotWithdrawNegativeAmount() throws BankAccountActionInvalidExcept
116116
bankAccount.withdraw(-5);
117117
}
118118

119-
@Ignore
119+
@Ignore("Remove to run test")
120120
@Test
121121
public void cannotGetBalanceOfClosedAccount() throws BankAccountActionInvalidException {
122122
bankAccount.open();
@@ -129,7 +129,7 @@ public void cannotGetBalanceOfClosedAccount() throws BankAccountActionInvalidExc
129129
bankAccount.getBalance();
130130
}
131131

132-
@Ignore
132+
@Ignore("Remove to run test")
133133
@Test
134134
public void cannotDepositMoneyIntoClosedAccount() throws BankAccountActionInvalidException {
135135
bankAccount.open();
@@ -141,7 +141,7 @@ public void cannotDepositMoneyIntoClosedAccount() throws BankAccountActionInvali
141141
bankAccount.deposit(5);
142142
}
143143

144-
@Ignore
144+
@Ignore("Remove to run test")
145145
@Test
146146
public void cannotWithdrawMoneyFromClosedAccount() throws BankAccountActionInvalidException {
147147
bankAccount.open();
@@ -154,7 +154,7 @@ public void cannotWithdrawMoneyFromClosedAccount() throws BankAccountActionInval
154154
bankAccount.withdraw(5);
155155
}
156156

157-
@Ignore
157+
@Ignore("Remove to run test")
158158
@Test
159159
public void bankAccountIsClosedBeforeItIsOpened() throws BankAccountActionInvalidException {
160160
expectedException.expect(BankAccountActionInvalidException.class);
@@ -163,7 +163,7 @@ public void bankAccountIsClosedBeforeItIsOpened() throws BankAccountActionInvali
163163
bankAccount.getBalance();
164164
}
165165

166-
@Ignore
166+
@Ignore("Remove to run test")
167167
@Test
168168
public void canAdjustBalanceConcurrently() throws BankAccountActionInvalidException, InterruptedException {
169169
bankAccount.open();

0 commit comments

Comments
 (0)