Skip to content

Added annotations for filtering test using annotations #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void setUp() {
}

@Test
@Annotation1
public void ensureSingleInputIsHandled() {
NativeScreenshot.capture("initial_state");
onView(withId(R.id.buttonOne)).perform(click());
Expand All @@ -44,6 +45,7 @@ public void ensureSingleInputIsHandled() {
}

@Test
@Annotation2
public void ensureMultipleInputIsHandled() {
NativeScreenshot.capture("initial_state");
onView(withId(R.id.buttonOne)).perform(click());
Expand Down