diff --git a/README.md b/README.md index 7e2f65c..22469cb 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,15 @@ ## Notes * You can view your test results on the [BrowserStack app-automate dashboard](https://www.browserstack.com/app-automate) +## Filtering +* You can filter your tests by passing annotation in the am command as well. This repository already contains 2 annotations @Annotation1 , @Annotation 2 + +* Usage + * This should only run tests with @Annotation1 + ``` + adb shell am instrument -w -e annotation com.sample.browserstack.samplecalculator.Annotation1 com.sample.browserstack.samplecalculator.test/androidx.test.runner.AndroidJUnitRunner + ``` + ## Additional Resources * [Customizing your tests on BrowserStack](https://www.browserstack.com/app-automate/capabilities) * [Browsers & mobile devices for app-automate testing on BrowserStack](https://www.browserstack.com/list-of-browsers-and-platforms?product=app_automate) diff --git a/app/src/androidTest/java/com/sample/browserstack/samplecalculator/Annotation1.java b/app/src/androidTest/java/com/sample/browserstack/samplecalculator/Annotation1.java new file mode 100644 index 0000000..69980c9 --- /dev/null +++ b/app/src/androidTest/java/com/sample/browserstack/samplecalculator/Annotation1.java @@ -0,0 +1,9 @@ +package com.sample.browserstack.samplecalculator; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@Inherited +public @interface Annotation1 { +} diff --git a/app/src/androidTest/java/com/sample/browserstack/samplecalculator/Annotation2.java b/app/src/androidTest/java/com/sample/browserstack/samplecalculator/Annotation2.java new file mode 100644 index 0000000..904a57e --- /dev/null +++ b/app/src/androidTest/java/com/sample/browserstack/samplecalculator/Annotation2.java @@ -0,0 +1,10 @@ +package com.sample.browserstack.samplecalculator; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@Inherited +public @interface Annotation2 { +} diff --git a/app/src/androidTest/java/com/sample/browserstack/samplecalculator/EnsureInputTests.java b/app/src/androidTest/java/com/sample/browserstack/samplecalculator/EnsureInputTests.java index a765e24..cb358fa 100644 --- a/app/src/androidTest/java/com/sample/browserstack/samplecalculator/EnsureInputTests.java +++ b/app/src/androidTest/java/com/sample/browserstack/samplecalculator/EnsureInputTests.java @@ -36,6 +36,7 @@ public void setUp() { } @Test + @Annotation1 public void ensureSingleInputIsHandled() { NativeScreenshot.capture("initial_state"); onView(withId(R.id.buttonOne)).perform(click()); @@ -44,6 +45,7 @@ public void ensureSingleInputIsHandled() { } @Test + @Annotation2 public void ensureMultipleInputIsHandled() { NativeScreenshot.capture("initial_state"); onView(withId(R.id.buttonOne)).perform(click());