Robotium : Android JUnit test annotations
|Annotations Available With Android JUnit Test:
Annotation type used to mark program elements that should no longer be used by programmers. |
|
Defines a meta-annotation for indicating that an annotation is documented and considered part of the public API. |
|
This annotation can be used on an InstrumentationTestCase‘s test methods. |
|
Defines a meta-annotation for indicating that an annotation is automatically inherited. |
|
Annotation that allows exposing methods to JavaScript. |
|
Marks a test that should run as part of the large tests. |
|
Marks a test that should run as part of the medium tests. |
|
Annotation type used to mark methods that override a method declaration in a superclass. |
|
This annotation indicates that a subclass of View is alllowed to be used with the RemoteViews mechanism. |
|
Defines a meta-annotation for determining the scope of retention for an annotation. |
|
Marks a test that should run as part of the small tests. |
|
Marks a test that should run as part of the smoke tests. |
|
Use this annotation on test classes or test methods that should not be included in a test suite. |
|
Indicates that Lint should ignore the specified warnings for the annotated element. |
|
Annotation type used to indicate that the compiler should not issue the specified warnings for the marked program element. |
|
Defines a meta-annotation for determining what ElementTypes an annotation can be applied to. |
|
Indicates that Lint should treat this type as targeting a given API level, no matter what the project target is. |
|
This @interface was deprecated in API level 14. Obsolete |
|
This @interface was deprecated in API level 14. Obsolete |
|
This annotation can be used on an InstrumentationTestCase‘s test methods. |
|
This annotation can be used to mark fields and methods to be dumped when the view is captured. |
|
This annotation can be used to mark fields and methods to be dumped by the view server. |
|
Defines a mapping from a flag to a String. |
|
Defines a mapping from an int value to a String. |
Most Frequently Used Annotations Are:
@Smoke
@SmallTest
@MediumTest
@LargeTest
@FlakyTest
Running Test Scripts For Specified Annotations From cmd:
adb shell am instrument -w -e size small Testprojectpackagename/android.test.InstrumentationTestRunner
Replace small with medium or large to run test methods belonging to @MediumTest and @LargeTest respectively.
If Junit Jmeter is used for XML report generation purpose, then replace android.test.InstrumentationTestRunner with com.zutubi.android.junitreport.JUnitReportTestRunner
@FlakyTest : This annotation is used for Repeatation of certain test suites.
e.g: @FlakyTest(tolerance=2) ; Replace 2 with the number of times you want to repeat that test suite.
Example of Annotations:
@SmallTest
public void testloginFunction()
{
//Clears Login field
solo.clearEditText(0);
//clears password field
solo.clearEditText(1);
//Clicks on the link ‘Forgot Password’/after clicking link opens in the browser.
//solo.clickOnText(“Forgot Password?”);
//solo.waitForDialogToOpen();
}
@MediumTest
//Navigates to previous activity from Browser.
//solo.goBack();
//Clicks on Cancel Button.
solo.clickOnButton(“Cancel”);
//waits for the dialogBox to come seeking confirmation of cancel.
solo.waitForDialogToOpen();
//Clicks on ‘No’ button on the dialogBox.
solo.clickOnButton(“No”);
//clicks on ‘Log In Button/note:login and password fields are empty.
solo.clickOnButton(“Log In”);
//verifies “* Fields are Empty/Not in valid Format” text comes in
assertTrue(solo.searchText(“* Fields are Empty/Not in valid Format”));
//enters spaces to login field and clicks login button.
solo.enterText(0, ” “);
solo.clickOnButton(“Log In”);
}
- Bring the auto Sync magic of Protractor to Selenium with Java - October 23, 2015
- Restarting Appium Server could improve various server freezing issues and may improve execution time - January 20, 2015
- Appium with iOS 8 and XCode 6 : What’s new? - November 5, 2014
- REST API automation testing using Apache HttpClient – The Approach - October 3, 2014
- An Overview of mobile application : Moving forward to automation - October 1, 2014
- An introduction to REST - September 29, 2014
- Run ChromeDriver with Chrome Driver Service to reduce script execution time significantly - September 26, 2014
- Selenium WebDriver – Get Cookies from an existing session and add those to a newly instantiated WebDriver browser instance. - September 26, 2014
- Simulate Copy Paste action using Java Robot and Clipboard class - September 26, 2014
- Android : How to test if Android Application has memory leaks - August 11, 2014