fladle icon indicating copy to clipboard operation
fladle copied to clipboard

Skip module if it has no tests

Open asadsalman opened this issue 3 years ago • 5 comments

If an Android module has no tests, we should be able to skip it automatically. The current behavior is:

RunTests
  No tests for mymodule-debug-androidTest.apk

  Saved 0 shards to android_shards.json

There are no tests to run.

> Task :mymodule:execFlank FAILED

This fails the task (and the entire run) even if all tests in other modules passed.

asadsalman avatar Mar 11 '21 23:03 asadsalman

Even a check as simple as the one connectedAndroidTest (DeviceProviderInstrumentTestTask) does should be fine.

asadsalman avatar Mar 11 '21 23:03 asadsalman

Thanks for the suggestion. What is the purpose of applying the plugin to a module without tests?

runningcode avatar Mar 12 '21 13:03 runningcode

Hi all. I have the same request.

The situation where this occurs:

  • We have code that applies the Fladle plugin to our project
  • We use AffectedModuleDetector and get a dynamic list of modules to run tests for which may or may not have Android Unit Tests.
  • Our dynamic configuration works great whenever we have Android Test APKs to run, but there are cases when all the affected modules only have JVM unit tests, we don't have any APKs. At this point in time we already have the finalizedBy(runFlanktask) set up, and there is no way to avoid running it at this point in time.

We get:

May  2 19:57:54.361: FAILURE: Build failed with an exception.
May  2 19:57:54.361: 
May  2 19:57:54.361: * What went wrong:
May  2 19:57:54.361: Execution failed for task ':writeConfigProps'.
May  2 19:57:54.361: > debugApk must be specified
May  2 19:57:54.361: 
May  2 19:57:54.361: * Try:
May  2 19:57:54.361: > Run with --info or --debug option to get more log output.
May  2 19:57:54.361: > Run with --scan to get full insights.

Idea I'll try that should hopefully work:

  • By using the technique @asadsalman called out, we can determine if any of the affected modules have Android tests, but we can't do that until afterEvaluate when the Android Plugin has been applied and available. At that point in time we can then determine if we want to programmatically add the dependsOn for the runFlankTask. That should work!

handstandsam avatar May 03 '22 02:05 handstandsam

I have a similar issue with a slightly different cause -

We have two configurations for Flank, one for our regular UI test suite and one for benchmark tests. Our default configuration does not run benchmark tests. We apply the plugin to a module that contains only benchmark tests, but when we run the runFlank task in our project it executes for that module as well and since it contains no tests runFlank fails.

bherbst avatar Jun 13 '22 19:06 bherbst