Skip to content
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

On-device test parser #539

Merged
merged 24 commits into from
Oct 28, 2021
Merged

On-device test parser #539

merged 24 commits into from
Oct 28, 2021

Conversation

Malinskiy
Copy link
Member

@Malinskiy Malinskiy commented Jul 6, 2021

Enabled on adam by default
Currently loses any annotations associated with tests unless a listener is attached to the test parsing, so annotation filter will not work. This is because am instrument doesn't output any annotations.

Closes #393
Depends on #538

@codecov-commenter
Copy link

codecov-commenter commented Jul 7, 2021

Codecov Report

Merging #539 (01c33b3) into develop (17f57be) will decrease coverage by 1.95%.
The diff coverage is 60.44%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #539      +/-   ##
=============================================
- Coverage      66.72%   64.76%   -1.96%     
- Complexity       539      687     +148     
=============================================
  Files            121      166      +45     
  Lines           2398     3312     +914     
  Branches         325      565     +240     
=============================================
+ Hits            1600     2145     +545     
- Misses           623      880     +257     
- Partials         175      287     +112     
Impacted Files Coverage Δ
...alinskiy/marathon/config/AnalyticsConfiguration.kt 75.00% <ø> (ø)
...y/marathon/config/LogicalConfigurationValidator.kt 0.00% <0.00%> (ø)
...malinskiy/marathon/config/ScreenRecordingPolicy.kt 100.00% <ø> (ø)
...hon/config/environment/EnvironmentConfiguration.kt 100.00% <ø> (ø)
...thon/config/environment/SystemEnvironmentReader.kt 83.33% <ø> (ø)
...rathon/config/exceptions/ConfigurationException.kt 33.33% <0.00%> (ø)
...nfig/serialization/time/InstantTimeProviderImpl.kt 100.00% <ø> (ø)
...lization/yaml/GraphiteConfigurationDeserializer.kt 18.18% <ø> (ø)
...n/yaml/RetentionPolicyConfigurationDeserializer.kt 42.10% <ø> (ø)
...athon/config/vendor/android/AllureConfiguration.kt 100.00% <ø> (ø)
... and 146 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17f57be...01c33b3. Read the comment docs.

… feature/device-test-parser

# Conflicts:
#	buildSrc/src/main/kotlin/Versions.kt
#	vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/RemoteFileManager.kt
@Malinskiy
Copy link
Member Author

There is an experimental way to extract annotations using on-device parser: https://github.com/Malinskiy/adam/blob/feature/test-meta-listener/android-junit4-listener/src/main/kotlin/com/malinskiy/adam/junit4/android/listener/TestAnnotationProducer.kt

The idea is to attach a RunListener to the execution using am instrument -e listener TestAnnotationProducer and parse the metrics outputted by test. One of those metrics will contain a list of annotations.

In order to use this users will have to declare a androidTestImplementation dependency with such listener and add an an instrumentationArgs parameter to the test parser:

vendorConfiguration:
  type: "Android"
....
  vendor: ADAM
  testParserConfiguration:
    type: "remote"
    instrumentationArgs:
      listener: "com.malinskiy.adam.junit4.android.listener.TestAnnotationProducer"

Then in the parser annotations will be picked up if present. To allow contract changes (e.g. annotation values) we have to version the instrumentation parameter name.

@Malinskiy Malinskiy marked this pull request as ready for review October 8, 2021 04:41
for (update in channel) {
if (update is DeviceProvider.DeviceEvent.DeviceConnected) {
val device = update.device as AdamAndroidDevice
return parseTests(device, configuration, vendorConfiguration, testBundles)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First connected device will be used for test parsing? Should we have some retry logic here to prevent flakiness if connection is not stable and so on?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do

# Conflicts:
#	buildSrc/src/main/kotlin/Versions.kt
#	cli/src/main/kotlin/com/malinskiy/marathon/cli/args/FileAndroidConfiguration.kt
#	cli/src/main/kotlin/com/malinskiy/marathon/cli/config/DeserializeModule.kt
#	configuration/src/main/kotlin/com/malinskiy/marathon/config/serialization/yaml/TestParserConfigurationDeserializer.kt
#	core/src/main/kotlin/com/malinskiy/marathon/execution/TestParser.kt
#	vendor/vendor-android/adam/src/main/kotlin/com/malinskiy/marathon/android/adam/AndroidDeviceTestRunner.kt
#	vendor/vendor-android/adam/src/main/kotlin/com/malinskiy/marathon/android/adam/di/Modules.kt
#	vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/AndroidTestParser.kt
#	vendor/vendor-android/base/src/main/kotlin/com/malinskiy/marathon/android/configuration/AndroidConfiguration.kt
#	vendor/vendor-android/base/src/test/kotlin/com/malinskiy/marathon/android/AndroidTestParserTest.kt
#	vendor/vendor-ios/src/main/kotlin/com/malinskiy/marathon/ios/IOSTestParser.kt
#	vendor/vendor-ios/src/test/kotlin/com/malinskiy/marathon/ios/IOSTestParserTest.kt
#	vendor/vendor-test/src/main/kotlin/com/malinskiy/marathon/test/factory/ConfigurationFactory.kt
- print message when test is ignored
- trim annotations when parsing
- fix test request for test without methods
- fix TestRunResultsListener to report null methods if they were requested
- fix cli package resource copying bug during build
…, add docs and an execution warning when no annotations are reported
tagantroy
tagantroy previously approved these changes Oct 25, 2021
@Malinskiy Malinskiy merged commit dc39786 into develop Oct 28, 2021
@Malinskiy Malinskiy deleted the feature/device-test-parser branch October 28, 2021 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] Named Parameterized tests will stay uncomplete
3 participants