-
-
Notifications
You must be signed in to change notification settings - Fork 126
Description
Is your feature request related to a problem? Please describe.
CustomFilter provides the ability to filter test run-time based on the characteristics of the device under test.
One use case we have -> We have a device pool consisting of tablet and phone devices. we want a test to be only executed on phone devices and similarly for tablet devices.
@Retention(value = AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
@CustomFilter(filterClass = TestDeviceFilter::class)
// TestDeviceFilter class contains logic to determine the device type and will evaluate if test should run or skipped
annotation class DeviceType(val deviceType: TestDeviceType)
@RunWith(AndroidJUnit4::class)
Class DeviceTypeTest {
@Test
@DeviceType(TestDeviceType.TABLET)
fun testFunctionOnTablet() {
}
@Test
@DeviceType(TestDeviceType.PHONE)
fun testFunctionOnPhone() {
}
}
testFunctionOnTablet()
should run on a tablet device and testFunctionOnPhone()
should run on a phone device with single gradle invocation.
./gradlew connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.sampleapp.espresso.DeviceTypeTest -Pandroid.testInstrumentationRunnerArguments.filter=com.sampleapp.espresso.filter.TestDeviceFilter
Describe the solution you'd like
It would be nice if Marathon supports this filtering as well. or, is there any marathon filtering I can use to achieve this desired result?
Describe alternatives you've considered
Is there a way to achieve this with a custom RunListener class?
Additional context
While trying to test this feature with Marathon, I noticed that Test Runner reported the test in the started phase but ended up with no test status being reported, and because of this marathon considered the test as an INCOMPLETE Test.
2024-07-10 13:06:54.972 15056-15083 TestRunner com.sampleapp.app I run started: 1 tests
2024-07-10 13:06:54.972 15056-15083 TestRunner com.sampleapp.app I run finished: 0 tests, 0 failed, 0 ignored