MarathonLabs / marathon

Cross-platform test runner
https://docs.marathonlabs.io
GNU General Public License v2.0
584 stars 122 forks source link

[Android] Observed minor package filtering issue in v0.9.0 #865

Closed kartik1o closed 1 year ago

kartik1o commented 1 year ago

Describe the bug Previously, when targeting tests to run with a package filtering, Marathon used to filter out the tests inside subpackage as well if any. However, it seems that after testClassRegexes, which used to default to ["^((?!Abstract).)*Tests$"] has been removed in V0.9.0. Now, when I want to filter test by package, which doesn't have immediate tests but have subpackages which consists of tests, marathon doesn't schedule any test run until I explicit filter tests with [com.test.package.*]

project-root/
│
├── app/
│   ├── src/
│   │   ├── main/
│   │   │   ├── java/
│   │   │   │   ├── com/
│   │   │   │   │   ├── app/
│   │   │   │   │   │   ├── package/
│   │   │   │   │   │   │   ├── MainActivity.java
│   │   │   │   │   │   │   ├── SubActivity.java
│   │   ├── androidTest/
│   │   │   ├── java/
│   │   │   │   ├── com/
│   │   │   │   │   ├── app/
│   │   │   │   │   │   ├── package/
│   │   │   │   │   │   │   ├── test/
│   │   │   │   │   │   │   │   ├── MainActivityTest.java
│   │   │   │   │   │   │   │   ├── SubActivityTest.java
├── .gitignore
├── build.gradle
└── README.md

To Reproduce Steps to reproduce the behaviour: 1 - package com.app.package which doesn't have any test and sub-package com.app.package.tests, with tests. 2 - add the package filtering configuration in config file. 3 - Execute marathon tests with package filter = [com.app.package]. 4 - Observe that it doesn't run any test which is inside a subpackage of the package.

Expected behavior Earlier until 0.8.4, [com.app.package] used to filter out tests inside any subpackages as well. [com.app.package] should be able to filter and execute tests inside sub-packages

Devices (please complete the following information): Any device/emulator running Android

Malinskiy commented 1 year ago

Are you still using testClassRegexes? Can you provide your configuration? The behaviour you're explaining is working as expected. Filtering subpackages can be done using regex appending the possibly missing suffix just as you mentioned, so for filtering com.example and all subpackages you would use:

filteringConfiguration:
  allowlist:
    - type: "package"
      regex: "com\.example.*"

This is also in the docs as an example https://docs.marathonlabs.io/runner/configuration/filtering#regex-filtering, so I think you were depending on undefined behaviour.

kartik1o commented 1 year ago

Are you still using testClassRegexes? Can you provide your configuration? The behaviour you're explaining is working as expected. Filtering subpackages can be done using regex appending the possibly missing suffix just as you mentioned, so for filtering com.example and all subpackages you would use:

filteringConfiguration:
  allowlist:
    - type: "package"
      regex: "com\.example.*"

This is also in the docs as an example https://docs.marathonlabs.io/runner/configuration/filtering#regex-filtering, so I think you were depending on undefined behaviour.

Thank for clarifying. I have updated test filter configuration to include suffix * for subpackage filtering. I guess testClassRegexes was doing this previously but as you mentioned this was undefined behaviour.