Skip to content

Commit

Permalink
Add tests to the sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelRocks committed Feb 22, 2018
1 parent ad1e6e1 commit a51e69b
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ ext {

androidToolsVersion = '3.0.1'
supportVersion = '27.0.2'

runnerVersion = '1.0.1'
espressoVersion = '3.0.1'
}
9 changes: 8 additions & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ android {
targetSdkVersion 27
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

signingConfigs {
Expand All @@ -32,7 +34,7 @@ android {

buildTypes {
debug {
minifyEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

Expand All @@ -46,4 +48,9 @@ android {

dependencies {
implementation "com.android.support:appcompat-v7:$supportVersion"

testImplementation "junit:junit:$junitVersion"

androidTestImplementation "com.android.support.test:runner:$runnerVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-core:$espressoVersion"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2018 Michael Rozumyanskiy
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.michaelrocks.paranoid.sample;

import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;


import static android.support.test.espresso.Espresso.onView;
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;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> activityRule = new ActivityTestRule<>(MainActivity.class);

@Test
public void textViewsHaveProperText() {
onView(withId(R.id.questionTextView))
.check(matches(withText("Q:\r\nHow does it work?")));
onView(withId(R.id.answerTextView))
.check(matches(withText("A:\r\nIt's magic! ¯\\_(ツ)_/¯")));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2018 Michael Rozumyanskiy
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.michaelrocks.paranoid.sample;

import org.junit.Test;


import static org.junit.Assert.assertTrue;

public class SampleTest {
@Test
public void runsJustFine() {
assertTrue(true);
}
}

0 comments on commit a51e69b

Please sign in to comment.