简体   繁体   中英

How to exclude test task when the gradle build task is run using Eclipse Buildship plugin?

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

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

将“-x test”添加到运行配置中的程序参数

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

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'
        }

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM