Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
apply plugin: 'com.android.application'
apply plugin: 'spoon'


buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.2.2'
}
}

android {
compileSdkVersion 26
Expand Down Expand Up @@ -27,4 +39,10 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestCompile 'com.squareup.spoon:spoon-client:1.7.1'
}

spoon {
debug = true
adbTimeout = 30
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -13,6 +14,7 @@
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import com.squareup.spoon.Spoon;

/**
* Espresso tests to ensure that editText box is updated appropriately
Expand All @@ -27,16 +29,27 @@ public class EnsureInputTests {
public ActivityTestRule<MainActivity> activityRule =
new ActivityTestRule<MainActivity>(MainActivity.class);

private MainActivity mainActivity;

@Before
public void setUp() {
mainActivity = activityRule.getActivity();
}

@Test
public void ensureSingleInputIsHandled() {
Spoon.screenshot(mainActivity, "initial_state");
onView(withId(R.id.buttonOne)).perform(click());
onView(withId(R.id.editText)).check(matches(withText("1")));
Spoon.screenshot(mainActivity, "post_multiple_btn_click");
}

@Test
public void ensureMultipleInputIsHandled() {
Spoon.screenshot(mainActivity, "initial_state");
onView(withId(R.id.buttonOne)).perform(click());
onView(withId(R.id.buttonTwo)).perform(click());
onView(withId(R.id.editText)).check(matches(withText("12")));
Spoon.screenshot(mainActivity, "post_multiple_btn_click");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -13,6 +14,7 @@
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import com.squareup.spoon.Spoon;

/**
* Espresso tests to ensure that simple operations result in
Expand All @@ -27,6 +29,14 @@ public class EnsureOperationTests {
public ActivityTestRule<MainActivity> activityRule =
new ActivityTestRule<MainActivity>(MainActivity.class);

private MainActivity mainActivity;

@Before
public void setUp() {
mainActivity = activityRule.getActivity();
}


@Test
public void ensureAdditionWorks() {
onView(withId(R.id.buttonOne)).perform(click());
Expand All @@ -36,6 +46,7 @@ public void ensureAdditionWorks() {
onView(withId(R.id.buttonOne)).perform(click());
onView(withId(R.id.buttonEqual)).perform(click());
onView(withId(R.id.editText)).check(matches(withText("33")));
Spoon.screenshot(mainActivity, "post_addition");
}

@Test
Expand All @@ -47,6 +58,7 @@ public void ensureSubtractionWorks() {
onView(withId(R.id.buttonOne)).perform(click());
onView(withId(R.id.buttonEqual)).perform(click());
onView(withId(R.id.editText)).check(matches(withText("11")));
Spoon.screenshot(mainActivity, "post_subtraction");
}

@Test
Expand All @@ -57,6 +69,7 @@ public void ensureMultiplicationWorks() {
onView(withId(R.id.buttonFive)).perform(click());
onView(withId(R.id.buttonEqual)).perform(click());
onView(withId(R.id.editText)).check(matches(withText("60")));
Spoon.screenshot(mainActivity, "post_multiplication");
}

@Test
Expand All @@ -67,5 +80,6 @@ public void ensureDivisionWorks() {
onView(withId(R.id.buttonThree)).perform(click());
onView(withId(R.id.buttonEqual)).perform(click());
onView(withId(R.id.editText)).check(matches(withText("4")));
Spoon.screenshot(mainActivity, "post_division");
}
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.browserstack.samplecalculator">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down