1

I am using Eclipse Buildship plugin for executing Gradle tasks on my project. Any idea how to exclude the test task when the build task is run? In Gradle STS plugin, I used to update the Program arguments to '-x test' which skipped the test task. When I tried the same with Buildship, getting the below error.

* What went wrong:
Task ' test' not found in root project
Kishore
  • 317
  • 2
  • 4
  • 17

5 Answers5

3

Have you considered running the "assemble" task instead of "build"?

:build
+--- :assemble
|    \--- :jar
|         \--- :classes
|              +--- :compileJava
|              \--- :processResources
\--- :check
     \--- :test
          +--- :classes
          |    +--- :compileJava
          |    \--- :processResources
          \--- :testClasses
               +--- :compileTestJava
               |    \--- :classes
               |         +--- :compileJava
               |         \--- :processResources
               \--- :processTestResources
lance-java
  • 25,497
  • 4
  • 59
  • 101
  • Thanks for the suggestion. Yes, assemble task helps me to skip the test task. Anyways, if there is a way to skip the test task when build task is run in Buildship, please share. Just curious!. – Kishore Nov 12 '20 at 05:50
1

Add "-x test" to the Program Arguments in Run Configuration

Sid J
  • 11
  • 1
0

For me. I had to put '-x' and 'test' on separate lines for BuildShip to work.

Randomizer
  • 93
  • 1
  • 4
0

In the build file add code to exclude test classes that are not to run.
If you exclude all your test classes, then it effectively is "skipping" the test step. Well, really the test step "runs" but no tests will run.
This is also handy while developing, but some tests are for dev work only, to be tidied up later. It also gives a good hint (or reminder) to other developers where to find operational dev tests.

// include this in your build.gradle file,
// and update the package selector lines    
    test { 
        // The excluded classes won't be called by the test step.
        // They're for manual calls during devwrk only.
            exclude 'devonly/sometests/**'
            exclude '**/Bar.class'
        }
Pete Kelley
  • 3,713
  • 2
  • 16
  • 17
0

Try adding -x and :test in two separate lines in Program Arguments section in Run Configurations

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33465099) – Parisa.H.R Dec 26 '22 at 09:24