Przeglądaj źródła

bank-account: add ignore hint and improve HINTS.md

Frida Tveit 9 lat temu
rodzic
commit
86faec5d9b

+ 5
- 1
exercises/bank-account/HINTS.md Wyświetl plik

@@ -4,4 +4,8 @@ To pass the last test you might find the
4 4
 
5 5
 Problems arising from running code concurrently are often intermittent because they depend on the order the code is
6 6
 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.

+ 13
- 13
exercises/bank-account/src/test/java/BankAccountTest.java Wyświetl plik

@@ -26,7 +26,7 @@ public class BankAccountTest {
26 26
         assertEquals(0, bankAccount.getBalance());
27 27
     }
28 28
 
29
-    @Ignore
29
+    @Ignore("Remove to run test")
30 30
     @Test
31 31
     public void canDepositMoney() throws BankAccountActionInvalidException {
32 32
         bankAccount.open();
@@ -36,7 +36,7 @@ public class BankAccountTest {
36 36
         assertEquals(10, bankAccount.getBalance());
37 37
     }
38 38
 
39
-    @Ignore
39
+    @Ignore("Remove to run test")
40 40
     @Test
41 41
     public void canDepositMoneySequentially() throws BankAccountActionInvalidException {
42 42
         bankAccount.open();
@@ -47,7 +47,7 @@ public class BankAccountTest {
47 47
         assertEquals(28, bankAccount.getBalance());
48 48
     }
49 49
 
50
-    @Ignore
50
+    @Ignore("Remove to run test")
51 51
     @Test
52 52
     public void canWithdrawMoney() throws BankAccountActionInvalidException {
53 53
         bankAccount.open();
@@ -58,7 +58,7 @@ public class BankAccountTest {
58 58
         assertEquals(5, bankAccount.getBalance());
59 59
     }
60 60
 
61
-    @Ignore
61
+    @Ignore("Remove to run test")
62 62
     @Test
63 63
     public void canWithdrawMoneySequentially() throws BankAccountActionInvalidException {
64 64
         bankAccount.open();
@@ -70,7 +70,7 @@ public class BankAccountTest {
70 70
         assertEquals(0, bankAccount.getBalance());
71 71
     }
72 72
 
73
-    @Ignore
73
+    @Ignore("Remove to run test")
74 74
     @Test
75 75
     public void cannotWithdrawMoneyFromEmptyAccount() throws BankAccountActionInvalidException {
76 76
         bankAccount.open();
@@ -81,7 +81,7 @@ public class BankAccountTest {
81 81
         bankAccount.withdraw(5);
82 82
     }
83 83
 
84
-    @Ignore
84
+    @Ignore("Remove to run test")
85 85
     @Test
86 86
     public void cannotWithdrawMoreMoneyThanYouHave() throws BankAccountActionInvalidException {
87 87
         bankAccount.open();
@@ -93,7 +93,7 @@ public class BankAccountTest {
93 93
         bankAccount.withdraw(7);
94 94
     }
95 95
 
96
-    @Ignore
96
+    @Ignore("Remove to run test")
97 97
     @Test
98 98
     public void cannotDepositNegativeAmount() throws BankAccountActionInvalidException {
99 99
         bankAccount.open();
@@ -104,7 +104,7 @@ public class BankAccountTest {
104 104
         bankAccount.deposit(-1);
105 105
     }
106 106
 
107
-    @Ignore
107
+    @Ignore("Remove to run test")
108 108
     @Test
109 109
     public void cannotWithdrawNegativeAmount() throws BankAccountActionInvalidException {
110 110
         bankAccount.open();
@@ -116,7 +116,7 @@ public class BankAccountTest {
116 116
         bankAccount.withdraw(-5);
117 117
     }
118 118
 
119
-    @Ignore
119
+    @Ignore("Remove to run test")
120 120
     @Test
121 121
     public void cannotGetBalanceOfClosedAccount() throws BankAccountActionInvalidException {
122 122
         bankAccount.open();
@@ -129,7 +129,7 @@ public class BankAccountTest {
129 129
         bankAccount.getBalance();
130 130
     }
131 131
 
132
-    @Ignore
132
+    @Ignore("Remove to run test")
133 133
     @Test
134 134
     public void cannotDepositMoneyIntoClosedAccount() throws BankAccountActionInvalidException {
135 135
         bankAccount.open();
@@ -141,7 +141,7 @@ public class BankAccountTest {
141 141
         bankAccount.deposit(5);
142 142
     }
143 143
 
144
-    @Ignore
144
+    @Ignore("Remove to run test")
145 145
     @Test
146 146
     public void cannotWithdrawMoneyFromClosedAccount() throws BankAccountActionInvalidException {
147 147
         bankAccount.open();
@@ -154,7 +154,7 @@ public class BankAccountTest {
154 154
         bankAccount.withdraw(5);
155 155
     }
156 156
 
157
-    @Ignore
157
+    @Ignore("Remove to run test")
158 158
     @Test
159 159
     public void bankAccountIsClosedBeforeItIsOpened() throws BankAccountActionInvalidException {
160 160
         expectedException.expect(BankAccountActionInvalidException.class);
@@ -163,7 +163,7 @@ public class BankAccountTest {
163 163
         bankAccount.getBalance();
164 164
     }
165 165
 
166
-    @Ignore
166
+    @Ignore("Remove to run test")
167 167
     @Test
168 168
     public void canAdjustBalanceConcurrently() throws BankAccountActionInvalidException, InterruptedException {
169 169
         bankAccount.open();