Slide 1

Slide 1 text

Jake Wharton Testing Robots

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

A View A

Slide 5

Slide 5 text

A View A Presenter A Model A

Slide 6

Slide 6 text

Presenter Model View A Unit Test A Fake Model

Slide 7

Slide 7 text

Presenter Model View Unit Test

Slide 8

Slide 8 text

View Presenter Model

Slide 9

Slide 9 text

View

Slide 10

Slide 10 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send

Slide 11

Slide 11 text

Send $42 to "[email protected]". Verify success. $0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send

Slide 12

Slide 12 text

• Enter "42" with the number pad. $0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send Send $42 to "[email protected]". Verify success.

Slide 13

Slide 13 text

Send $42 to "[email protected]". Verify success. • Enter "42" with the number pad. • Tap on the input box marked "Recipient". $0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send

Slide 14

Slide 14 text

Send $42 to "[email protected]". Verify success. • Enter "42" with the number pad. • Tap on the input box marked "Recipient". • Type "[email protected]". $0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send

Slide 15

Slide 15 text

Send $42 to "[email protected]". Verify success. • Enter "42" with the number pad. • Tap on the input box marked "Recipient". • Type "[email protected]". • Press the button marked "Send". $0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send

Slide 16

Slide 16 text

Send $42 to "[email protected]". Verify success. • Enter "42" with the number pad. • Tap on the input box marked "Recipient". • Type "[email protected]". • Press the button marked "Send". • Verify success screen is shown. $0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send

Slide 17

Slide 17 text

PaymentScreen pay = (PaymentScreen) obtainScreen(); $0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send

Slide 18

Slide 18 text

PaymentScreen pay = (PaymentScreen) obtainScreen();
 pay.amountView.setValue(42_00);
 pay.recipientView.setText("[email protected]"); $0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send

Slide 19

Slide 19 text

PaymentScreen pay = (PaymentScreen) obtainScreen();
 pay.amountView.setValue(42_00);
 pay.recipientView.setText("[email protected]");
 pay.sendView.click(); $0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send

Slide 20

Slide 20 text

PaymentScreen pay = (PaymentScreen) obtainScreen();
 pay.amountView.setValue(42_00);
 pay.recipientView.setText("[email protected]");
 pay.sendView.click();
 
 Thread.sleep(1000); $0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send

Slide 21

Slide 21 text

PaymentScreen pay = (PaymentScreen) obtainScreen();
 pay.amountView.setValue(42_00);
 pay.recipientView.setText("[email protected]");
 pay.sendView.click();
 
 Thread.sleep(1000);
 
 assertThat(obtainScreen())
 .isInstanceOf(SuccessScreen.class); $0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send

Slide 22

Slide 22 text

A Test A PaymentScreen pay = (PaymentScreen) obtainScreen();
 pay.amountView.setValue(42_00);
 pay.recipientView.setText("[email protected]");
 pay.sendView.click();
 
 Thread.sleep(1000);
 
 assertThat(obtainScreen())
 .isInstanceOf(SuccessScreen.class); Presenter View Fake Model

Slide 23

Slide 23 text

Presenter View Fake Model A Test A

Slide 24

Slide 24 text

Presenter A View A Fake Model Test

Slide 25

Slide 25 text

Presenter Fake Model Test View Send $42 to "[email protected]". Verify success.

Slide 26

Slide 26 text

Presenter View Fake Model Test

Slide 27

Slide 27 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send findViewWithText("4").click();
 findViewWithText("2").click();

Slide 28

Slide 28 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send findViewWithText("4").click();
 findViewWithText("2").click();
 findViewWithHint("Recipient").setText("[email protected]");

Slide 29

Slide 29 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send findViewWithText("4").click();
 findViewWithText("2").click();
 findViewWithHint("Recipient").setText("[email protected]");
 findViewWithText("Send").click();

Slide 30

Slide 30 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send findViewWithText("4").click();
 findViewWithText("2").click();
 findViewWithHint("Recipient").setText("[email protected]");
 findViewWithText("Send").click();
 
 Thread.sleep(1000);

Slide 31

Slide 31 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send findViewWithText("4").click();
 findViewWithText("2").click();
 findViewWithHint("Recipient").setText("[email protected]");
 findViewWithText("Send").click();
 
 Thread.sleep(1000);
 
 findViewWithText("Success!");

Slide 32

Slide 32 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send onView(withText("4")).perform(click());
 onView(withText("2")).perform(click());
 onView(withHint("Recipient")).perform(typeText("[email protected]"));
 onView(withText("Send")).perform(click());
 
 onView(withText("Success!")).check(visible()); find W 
 find W 
 find W .set 
 find W 
 Thread.sleep(1000);
 
 find W

Slide 33

Slide 33 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send onView(withText("4")).perform(click());
 onView(withText("2")).perform(click());
 onView(withHint("Recipient")) .perform(typeText("[email protected]"));
 onView(withText("Send")).perform(click());
 
 onView(withText("Success!")).check(visible()); Send $42 to "[email protected]". Verify success.

Slide 34

Slide 34 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send onView(withText("4")).perform(click());
 onView(withText("2")).perform(click());
 onView(withHint("Recipient")) .perform(typeText("[email protected]"));
 onView(withText("Send")).perform(click());
 
 onView(withText("Success!")).verify(visible()); Send $42 to "[email protected]". Verify success. What How

Slide 35

Slide 35 text

Presenter View Fake Model Test

Slide 36

Slide 36 text

Presenter View Fake Model Test What How

Slide 37

Slide 37 text

Presenter View Fake Model Test What How What & How

Slide 38

Slide 38 text

Presenter View Fake Model Robot Test What How What How

Slide 39

Slide 39 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send class PaymentRobot {
 }A

Slide 40

Slide 40 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send class PaymentRobot {
 PaymentRobot amount(long amount) {
 // ...
 }B
 }A

Slide 41

Slide 41 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send class PaymentRobot {
 PaymentRobot amount(long amount) {
 // ...
 }B
 
 PaymentRobot recipient(String recipient) {
 // ...
 }C
 }A

Slide 42

Slide 42 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send class PaymentRobot {
 PaymentRobot amount(long amount) {
 // ...
 }B
 
 PaymentRobot recipient(String recipient) {
 // ...
 }C
 
 PaymentRobot send() {
 // ...
 }D
 }A

Slide 43

Slide 43 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send class PaymentRobot {
 PaymentRobot amount(long amount) {
 // ...
 }B
 
 PaymentRobot recipient(String recipient) {
 // ...
 }C
 
 ResultRobot send() {
 // ...
 }D
 }A
 
 class ResultRobot {
 }E 
 
 
 
 
 
 
 
 Payment

Slide 44

Slide 44 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send class PaymentRobot {
 PaymentRobot amount(long amount) {
 // ...
 }B
 
 PaymentRobot recipient(String recipient) {
 // ...
 }C
 
 ResultRobot send() {
 // ...
 }D
 }A
 
 class ResultRobot {
 ResultRobot isSuccess() {
 // ...
 }F
 }E

Slide 45

Slide 45 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send class PaymentRobot {
 PaymentRobot amount(long amount) {
 long dollars = amount / 100;
 String dollarString = String.valueOf(dollars);
 for (int i = 0; i < dollarString.length(); i++) {
 onView(withText(dollarString.substring(i, i + 1))).perform(click());
 }
 long cents = amount - (dollars * 100);
 if (cents != 0) {
 onView(withText(".")).perform(click());
 String centsString = String.valueOf(cents);
 for (int i = 0; i < centsString.length(); i++) {
 onView(withText(centsString.substring(i, i + 1))).perform(click());
 }
 }
 return this;
 }B
 
 PaymentRobot recipient(String recipient) {
 onView(withHint("Recipient")).perform(typeType("[email protected]"));
 return this;
 }C
 
 ResultRobot send() {
 onView(withText("Send")).perform(click());
 return new ResultRobot();
 }D
 }A
 
 class ResultRobot {
 ResultRobot isSuccess() {
 onView(withText("Success!")).verify(visible());
 return this;
 }F
 }E

Slide 46

Slide 46 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send PaymentRobot payment = new PaymentRobot();

Slide 47

Slide 47 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send PaymentRobot payment = new PaymentRobot();
 payment.amount(42_00);

Slide 48

Slide 48 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send PaymentRobot payment = new PaymentRobot();
 payment.amount(42_00);
 payment.recipient("[email protected]");

Slide 49

Slide 49 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send PaymentRobot payment = new PaymentRobot();
 payment.amount(42_00);
 payment.recipient("[email protected]")
 payment.send();

Slide 50

Slide 50 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send PaymentRobot payment = new PaymentRobot();
 payment.amount(42_00);
 payment.recipient("[email protected]")
 ResultRobot result = payment.send();

Slide 51

Slide 51 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send PaymentRobot payment = new PaymentRobot();
 payment.amount(42_00);
 payment.recipient("[email protected]")
 ResultRobot result = payment.send(); result.isSuccess();

Slide 52

Slide 52 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send PaymentRobot payment = new PaymentRobot();
 ResultRobot result = payment
 .amount(42_00)
 .recipient("[email protected]")
 .send();
 result.isSuccess();

Slide 53

Slide 53 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send PaymentRobot payment = new PaymentRobot();
 ResultRobot result = payment
 .amount(42_00)
 .recipient("[email protected]")
 .send();
 result.isSuccess(); Send $42 to "[email protected]". Verify success.

Slide 54

Slide 54 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send PaymentRobot payment = new PaymentRobot();
 ResultRobot result = payment
 .amount(42_00)
 .recipient("[email protected]")
 .send();
 result.isSuccess(); Send $42 to "[email protected]". Verify success. What

Slide 55

Slide 55 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send class PaymentRobot {
 PaymentRobot amount(long amount) {
 long dollars = amount / 100;
 String dollarString = String.valueOf(dollars);
 for (int i = 0; i < dollarString.length(); i++) {
 onView(withText(dollarString.substring(i, i + 1))).perform(click());
 }
 long cents = amount - (dollars * 100);
 if (cents != 0) {
 onView(withText(".")).perform(click());
 String centsString = String.valueOf(cents);
 for (int i = 0; i < centsString.length(); i++) {
 onView(withText(centsString.substring(i, i + 1))).perform(click());
 }
 }
 return this;
 }B
 
 PaymentRobot recipient(String recipient) {
 onView(withHint("Recipient")).perform(typeType("[email protected]"));
 return this;
 }C
 
 ResultRobot send() {
 onView(withText("Send")).perform(click());
 return new ResultRobot();
 }D
 }A
 
 class ResultRobot {
 ResultRobot isSuccess() {
 onView(withText("Success!")).verify(visible());
 return this;
 }F
 }E How

Slide 56

Slide 56 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send PaymentRobot payment = new PaymentRobot();
 ResultRobot result = payment
 .amount(42_00)
 .recipient("[email protected]")
 .send();
 result.isSuccess();

Slide 57

Slide 57 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send @Test public void singleFundingSourceSuccess() {
 PaymentRobot payment = new PaymentRobot();
 
 ResultRobot result = payment
 .amount(42_00)
 .recipient("[email protected]")
 .send();
 
 result.isSuccess();
 }A

Slide 58

Slide 58 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send @Test public void singleFundingSourceSuccess() {
 PaymentRobot payment = new PaymentRobot();
 
 ResultRobot result = payment
 .amount(42_00)
 .recipient("[email protected]")
 .send();
 
 result.isSuccess();
 }A
 
 @Test public void singleFundingSourceTooMuch() {
 PaymentRobot payment = new PaymentRobot();
 
 ResultRobot result = payment
 .amount(1_000_000_00)
 .recipient("[email protected]")
 .send();
 
 result.isSuccess();
 }B

Slide 59

Slide 59 text

$0 1 2 3 4 5 6 7 8 9 0 < . Recipient Send @Test public void singleFundingSourceSuccess() {
 PaymentRobot payment = new PaymentRobot();
 
 ResultRobot result = payment
 .amount(42_00)
 .recipient("[email protected]")
 .send();
 
 result.isSuccess();
 }A
 
 @Test public void singleFundingSourceTooMuch() {
 PaymentRobot payment = new PaymentRobot();
 
 ResultRobot result = payment
 .amount(1_000_000_00)
 .recipient("[email protected]")
 .send();
 
 result.isSuccess();
 }B 
 
 @Test public void singleFundingSourceInsufficientFunds() {
 PaymentRobot payment = new PaymentRobot();
 
 ResultRobot result = payment
 .amount(1_000_00)
 .recipient("[email protected]")
 .send();
 
 result.isSuccess();
 }C

Slide 60

Slide 60 text

@Test public void singleFundingSourceSuccess() {
 PaymentRobot payment = new PaymentRobot();
 
 ResultRobot result = payment
 .amount(42_00)
 .recipient("[email protected]")
 .send();
 
 result.isSuccess();
 }A
 
 @Test public void singleFundingSourceTooMuch() {
 PaymentRobot payment = new PaymentRobot();
 
 ResultRobot result = payment
 .amount(1_000_000_00)
 .recipient("[email protected]")
 .send();
 
 result.isSuccess();
 }B 
 
 @Test public void singleFundingSourceInsufficientFunds() {
 PaymentRobot payment = new PaymentRobot();
 
 ResultRobot result = payment
 .amount(1_000_00)
 .recipient("[email protected]")
 .send();
 
 result.isSuccess();
 }C 
 @Test public void networkErrorAllowsRetry() {
 // ...
 } 
 
 
 
 @Test public void multipleFundingSourcesSuccess() {
 // ...
 } 
 
 
 
 
 
 
 
 
 @Test public void multipleFundingSourcesOneDisabled() {
 // ...
 } 
 
 
 
 
 
 
 
 
 
 
 
 
 @Test public void multipleFundingSourcesInsufficientUsesOther() {
 // ...
 } 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 @Test public void multipleFundingSourcesAllInsufficient() {
 // ...
 } 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 @Test public void unauthenticatedLogsOut() {
 // ...
 } 
 @Test public void rotationRetainsAmountAndRecipient() {
 // ...
 } 
 
 @Test public void serverErrorShowsTryAgainLater() {
 // ...
 }

Slide 61

Slide 61 text

Presenter View Fake Model Robot Test

Slide 62

Slide 62 text

Presenter View Fake Model Robot Test Test Test Test Test Test Test Test Test Test Test

Slide 63

Slide 63 text

PaymentRobot payment = new PaymentRobot();
 ResultRobot result = payment
 .amount(42_00)
 .recipient("[email protected]")
 .send();
 result.isSuccess();

Slide 64

Slide 64 text

class PaymentRobot {
 PaymentRobot amount(long amount) {A
 // ...
 }B
 
 PaymentRobot recipient(String recipient) {B
 // ...
 }C
 
 ResultRobot send() {C
 // ...
 }D
 }A
 
 class ResultRobot {
 ResultRobot isSuccess() {D
 // ...
 }F
 }E

Slide 65

Slide 65 text

class PaymentRobot {
 fun amount(amount: Long): PaymentRobot {A
 // ...
 }B 
 fun recipient(recipient: String): PaymentRobot {B
 // ...
 }C
 
 fun send(): ResultRobot {C
 // ...
 }D
 }A 
 class ResultRobot {
 fun isSuccess(): ResultRobot {D
 // ...
 }F
 }E

Slide 66

Slide 66 text

val
 
 val PaymentRobot payment = new PaymentRobot();
 ResultRobot result = payment
 .amount(42_00)
 .recipient("[email protected]")
 .send();
 result.isSuccess();

Slide 67

Slide 67 text

val payment = PaymentRobot()
 
 val result = payment
 .amount(4200)
 .recipient("[email protected]")
 .send()
 
 result.isSuccess()

Slide 68

Slide 68 text

class PaymentRobot {
 fun amount(amount: Long): PaymentRobot {A
 // ...
 }B 
 fun recipient(recipient: String): PaymentRobot {B
 // ...
 }C
 
 fun send(): ResultRobot {C
 // ...
 }D
 }A 
 class ResultRobot {
 fun isSuccess(): ResultRobot {D
 // ...
 }F
 }E

Slide 69

Slide 69 text

class PaymentRobot {
 fun amount(amount: Long) {A
 // ...
 }B 
 fun recipient(recipient: String) {B
 // ...
 }C
 
 fun send(): ResultRobot {C
 // ...
 }D
 }A 
 class ResultRobot {
 fun isSuccess() {D
 // ...
 }F
 }E

Slide 70

Slide 70 text

fun payment() = PaymentRobot() class PaymentRobot {
 fun amount(amount: Long) {A
 // ...
 }B 
 fun recipient(recipient: String) {B
 // ...
 }C
 
 fun send(): ResultRobot {C
 // ...
 }D
 }A 
 class ResultRobot {
 fun isSuccess() {D
 // ...
 }F
 }E

Slide 71

Slide 71 text

fun payment(func: PaymentRobot.() -> Unit) = PaymentRobot() class PaymentRobot {
 fun amount(amount: Long) {A
 // ...
 }B 
 fun recipient(recipient: String) {B
 // ...
 }C
 
 fun send(): ResultRobot {C
 // ...
 }D
 }A 
 class ResultRobot {
 fun isSuccess() {D
 // ...
 }F
 }E

Slide 72

Slide 72 text

fun payment(func: PaymentRobot.() -> Unit) = PaymentRobot().apply { func() } class PaymentRobot {
 fun amount(amount: Long) {A
 // ...
 }B 
 fun recipient(recipient: String) {B
 // ...
 }C
 
 fun send(): ResultRobot {C
 // ...
 }D
 }A 
 class ResultRobot {
 fun isSuccess() {D
 // ...
 }F
 }E

Slide 73

Slide 73 text

fun payment(func: PaymentRobot.() -> Unit) = PaymentRobot().apply { func() } class PaymentRobot {
 fun amount(amount: Long) {A
 // ...
 }B 
 fun recipient(recipient: String) {B
 // ...
 }C
 
 fun send(): ResultRobot {C
 // ...
 }D
 }A 
 class ResultRobot {
 fun isSuccess() {D
 // ...
 }F
 }E

Slide 74

Slide 74 text

val payment = PaymentRobot()
 
 val result = payment
 .amount(4200)
 .recipient("[email protected]")
 .send()
 
 result.isSuccess()

Slide 75

Slide 75 text

val result = payment {
 amount(4200)
 recipient("[email protected]")
 }.send()
 
 result.isSuccess()

Slide 76

Slide 76 text

fun payment(func: PaymentRobot.() -> Unit) = PaymentRobot().apply { func() } class PaymentRobot {
 fun amount(amount: Long) {A
 // ...
 }B 
 fun recipient(recipient: String) {B
 // ...
 }C
 
 fun send(): ResultRobot {C
 // ...
 }D
 }A 
 class ResultRobot {
 fun isSuccess() {D
 // ...
 }F
 }E

Slide 77

Slide 77 text

fun payment(func: PaymentRobot.() -> Unit) = PaymentRobot().apply { func() } class PaymentRobot {
 fun amount(amount: Long) {A
 // ...
 }B 
 fun recipient(recipient: String) {B
 // ...
 }C
 
 fun send(func: ResultRobot.() -> Unit): ResultRobot {C
 // ... return ResultRobot().apply { func() }
 }D
 }A 
 class ResultRobot {
 fun isSuccess() {D
 // ...
 }F
 }E

Slide 78

Slide 78 text

fun payment(func: PaymentRobot.() -> Unit) = PaymentRobot().apply { func() } class PaymentRobot {
 fun amount(amount: Long) {A
 // ...
 }B 
 fun recipient(recipient: String) {B
 // ...
 }C
 
 fun send(func: ResultRobot.() -> Unit): ResultRobot {C
 // ... return ResultRobot().apply { func() }
 }D
 }A 
 class ResultRobot {
 fun isSuccess() {D
 // ...
 }F
 }E

Slide 79

Slide 79 text

val result = payment {
 amount(4200)
 recipient("[email protected]")
 }.send()
 
 result.isSuccess()

Slide 80

Slide 80 text

payment {
 amount(4200)
 recipient("[email protected]")
 }.send {
 isSuccess()
 }A

Slide 81

Slide 81 text

fun payment(func: PaymentRobot.() -> Unit) = PaymentRobot().apply { func() } class PaymentRobot {
 fun amount(amount: Long) {A
 // ...
 }B 
 fun recipient(recipient: String) {B
 // ...
 }C
 
 fun send(func: ResultRobot.() -> Unit): ResultRobot {C
 // ... return ResultRobot().apply { func() }
 }D
 }A 
 class ResultRobot {
 fun isSuccess() {D
 // ...
 }F
 }E

Slide 82

Slide 82 text

fun payment(func: PaymentRobot.() -> Unit) = PaymentRobot().apply { func() } class PaymentRobot {
 fun amount(amount: Long) {A
 // ...
 }B 
 fun recipient(recipient: String) {B
 // ...
 }C
 
 infix fun send(func: ResultRobot.() -> Unit): ResultRobot {C
 // ... return ResultRobot().apply { func() }
 }D
 }A 
 class ResultRobot {
 fun isSuccess() {D
 // ...
 }F
 }E

Slide 83

Slide 83 text

fun payment(func: PaymentRobot.() -> Unit) = PaymentRobot().apply { func() } class PaymentRobot {
 fun amount(amount: Long) {A
 // ...
 }B 
 fun recipient(recipient: String) {B
 // ...
 }C
 
 infix fun send(func: ResultRobot.() -> Unit): ResultRobot {C
 // ... return ResultRobot().apply { func() }
 }D
 }A 
 class ResultRobot {
 fun isSuccess() {D
 // ...
 }F
 }E

Slide 84

Slide 84 text

payment {
 amount(4200)
 recipient("[email protected]")
 } send {
 isSuccess()
 }A .

Slide 85

Slide 85 text

payment {
 amount(4200)
 recipient("[email protected]")
 } send {
 isSuccess()
 }A

Slide 86

Slide 86 text

payment { 
 amount(4200)
 recipient("[email protected]")
 } send {
 isSuccess()
 }A Screen entry point Actions and/or assertions Screen transition Actions and/or assertions

Slide 87

Slide 87 text

Exception in thread "main" java.lang.AssertionError: Expected but found at ResultRobot.isSuccess(ResultRobot.kt:18) at PaymentTest$singleFundingSourceSuccess$2.invoke(PaymentTest.kt:27) at PaymentRobot.send(PaymentRobot.kt:13) at PaymentTest.singleFundingSourceSuccess(PaymentTest.kt:8)

Slide 88

Slide 88 text

payment {
 amount(4200)
 recipient("[email protected]") } send { isSuccess() }A

Slide 89

Slide 89 text

payment {
 amount(4200)
 recipient("[email protected]") send() } birthday { date(1970, 1, 1) next() } ssn { value("123-56-7890") next() } result { isSuccess() }A

Slide 90

Slide 90 text

fun payment(func: PaymentRobot.() -> Unit) = PaymentRobot().apply { func() }

Slide 91

Slide 91 text

fun payment(func: PaymentRobot.() -> Unit) { onView(withText("$0")).check(visible()) return PaymentRobot().apply { func() } }

Slide 92

Slide 92 text

fun payment(func: PaymentRobot.() -> Unit) { onView(withText("$0")).check(visible()) return PaymentRobot().apply { func() } } fun birthdate(func: BirthdateRobot.() -> Unit) { onView(withText("Enter birth date:")).check(visible()) return BirthdateRobot().apply { func() } } fun ssn(func: SsnRobot.() -> Unit) { onView(withText("Enter social security number:")).check(visible()) return SsnRobot().apply { func() } } fun result(func: ResultRobot.() -> Unit) { return ResultRobot().apply { func() } }

Slide 93

Slide 93 text

Presenter View Model Robot Test

Slide 94

Slide 94 text

Presenter View Model Robot Test Application Architecture

Slide 95

Slide 95 text

Presenter View Model Robot Test UI Test Architecture

Slide 96

Slide 96 text

jakewharton jakewharton jakewharton twitter.com/ google.com/+ .com Testing Robots