/*Espresso testing */ | |
androidTestImplementation 'com.android.support.test:runner:1.0.2' | |
androidTestImplementation 'com.android.support.test:rules:1.0.2' | |
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' |
Full code of dependency:CODE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
android { | |
compileSdkVersion 28 | |
defaultConfig { | |
applicationId "app.itech.com.myapplication" | |
minSdkVersion 17 | |
targetSdkVersion 28 | |
versionCode 1 | |
versionName "1.0" | |
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | |
} | |
buildTypes { | |
release { | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
} | |
} | |
} | |
dependencies { | |
implementation fileTree(dir: 'libs', include: ['*.jar']) | |
implementation 'com.android.support:appcompat-v7:28.0.0' | |
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | |
testImplementation 'junit:junit:4.12' | |
/*Espresso testing */ | |
androidTestImplementation 'com.android.support.test:runner:1.0.2' | |
androidTestImplementation 'com.android.support.test:rules:1.0.2' | |
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | |
} |
Toast message check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* **************************************************************************** | |
* * Created by : Md Amirul Islam on 11/3/2018 at 8.11 PM. | |
* * Email : amirul.csejust@gmail.com | |
* * | |
* * Purpose: To test all element of UI | |
* * | |
* * Last edited by : Md Amirul Islam on 11/3/2018. | |
* * | |
* * Last Reviewed by : <Reviewer Name> on <mm/dd/yy> | |
* **************************************************************************** | |
*/ | |
public class ToastMegCheckTest { | |
@Rule | |
public ActivityTestRule<ToastMegCheck> mToastMegCheckTest = new ActivityTestRule<>(ToastMegCheck.class); | |
/* | |
* Below two method needs if want some DB (Database) or network operation and we need setup some | |
* important things like DB connection established or DB close. | |
* But now we are not use it | |
* */ | |
@Before | |
public void setUp() throws Exception { | |
} | |
@After | |
public void tearDown() throws Exception { | |
} | |
@Test | |
public void showEditTextName() { | |
// now write in edit text | |
onView(withId(R.id.etTest)).perform(typeText("amirul")); | |
delay(500); | |
// now press b Button | |
onView(withId(R.id.btnSubmit)).perform(click()); | |
// now check toast is properly showing or not | |
onView(withText("amirul")).inRoot(withDecorView(not(is(mToastMegCheckTest.getActivity().getWindow().getDecorView())))).check(matches(isDisplayed())); | |
} | |
private void delay(long item) { | |
try { | |
Thread.sleep(item); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Code END