Test throws UnsupportedOperationException as expected.
authorGustavo Martin Morcuende <gustavo.martin@scmspain.com>
Sun, 4 Dec 2016 15:18:39 +0000 (16:18 +0100)
committerGustavo Martin Morcuende <gustavo.martin@scmspain.com>
Sun, 4 Dec 2016 15:18:39 +0000 (16:18 +0100)
You should configure your IDE for throwing UnsupportedOperationException
whenever it automatically creates a method. In this way, when running
our unit tests we are able to find out what is not yet implemented.

TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Account.java [new file with mode: 0644]
TDD/sandromancuso/bank/src/test/java/org/craftedsw/feature/PrintStatementFeature.java

diff --git a/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Account.java b/TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Account.java
new file mode 100644 (file)
index 0000000..348f65f
--- /dev/null
@@ -0,0 +1,20 @@
+package org.craftedsw.feature;
+
+public class Account {
+
+       public void deposit(int amount) {
+               // IDE configuration for always throwing this exception
+               // when automatically creating methods.
+               // In this way, when running our unit tests we are
+               // able to find out what is not yet implemented.
+               throw new UnsupportedOperationException();
+       }
+
+       public void withdraw(int amount) {
+               throw new UnsupportedOperationException();
+       }
+
+       public void printStatement() {
+               throw new UnsupportedOperationException();
+       }
+}
index e2c6f1c..d65b95a 100644 (file)
@@ -2,6 +2,7 @@ package org.craftedsw.feature;
 
 import static org.mockito.Mockito.verify;
 
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -11,10 +12,16 @@ import org.mockito.runners.MockitoJUnitRunner;
 public class PrintStatementFeature {
 
        @Mock private Console console;
+       private Account account;
+       
+       @Before
+       public void initialise() {
+               account = new Account();
+       }
        
        @Test public void
        print_statement_containing_all_transactions() {
-               account.deposti(1000);
+               account.deposit(1000);
                // No negative value, instead we use the verb withdraw.
                // Semantics are very important in the code!!!
                account.withdraw(100);