title: How to run one test from a subproject with gradlew?
body: <p>I have a multi-project build in gradle. It is an android project and the test in question does run when I execute it manually in android studio.
  The structure of the project is as follows:</p>
  <pre><code>.../my-app$ ./gradlew -q projects
  [...]
  Root project 'my-app'
  +--- Project ':myapp'
  \--- Project ':mymodel'
  [...]
  </code></pre>
  <p>I want to execute a single test (class) in <code>:myapp</code>.
  Due to version constraints I have to use <code>gradlew</code> from the project root directory.</p>
  <p>The right command to execute a single test seems to be
  <code>./gradlew test --tests my.project.MyTest</code> but I don't know how to do it with subprojects.</p>
  <p>If I run <code>./gradlew test --tests my.project.MyTest</code> I get</p>
  <pre><code>FAILURE: Build failed with an exception.
  
  * What went wrong:
  Problem configuring task :myapp:test from command line.
  &gt; Unknown command-line option '--tests'.
  </code></pre>
  <p>with the suggestion to  run <code>gradle help --task :myapp:test</code>
  That yields</p>
  <pre><code>&gt; Task :help
  Detailed task information for :myapp:test
  
  Path
       :myapp:test
  
  Type
       Task (org.gradle.api.Task)
  
  Description
       Run unit tests for all variants.
  
  Group
       verification
  </code></pre>
  <p>and no command line options at all, so I assume I can just leave it out.</p>
  <p><code>./gradlew test my.project.MyTest</code> gives<br />
  <code>Task 'my.project.MyTest' not found in root project 'my-app'.</code><br />
  same for <code>./gradlew :myapp:test my.project.MyTest</code>.</p>
  <p><a href="https://stackoverflow.com/a/42262678">This answer</a> to an older question suggests spelling out the variant name which is <code>./gradlew :myapp:testReleaseUnitTest --tests my.project.MyTest</code> for me and that yields</p>
  <pre><code>&gt; Task :myapp:testReleaseUnitTest FAILED
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':myapp:testReleaseUnitTest'.
  &gt; No tests found for given includes: [my.project.MyTest](--tests filter)
  </code></pre>
  <p><code>./gradlew --version</code> is <code>7.1</code>, I've just upgraded to it with <code>./gradlew wrapper --gradle-version 7.1</code> and <code>gradle wrapper</code>.<br />
  I'm out of ideas at this point. What am I doing wrong? How can I run a single test in the command line?</p>