How to call "exclude" pattern on tests before execution?

(Phil Swenson) #1

We have some tests that are broken and we don’t have the time to fix them (or even know how to fix them). We have split our tests into many different tasks because they take so long to execute and this allows us to use separate jenkins nodes to execute them in parallel.

So we have tasks like:

task itestGeneral(type: Test) {
    include '**/general/*IntegrationTest.*'
    include "**/deployer/*IntegrationTest.*"
  task itestKpi(type: Test) {
    include '**/kpi/*IntegrationTest.*'

I want these itest tasks to skip the known “broken tests” I tried writing code such as below to filter them out:

def brokenTestPatterns = ["ProcessInstIdIntegrationTest", "MapiPushProcessDataIntegrationTest",
        "StatsMultipleDayOneHourIntervalIntegrationTest", "AggregationIntegrationTest", "SimpleRuleInstIntegrationTest",
        "KPIStatsDiagRuleBackPopIntegrationTest", "SimpleRuleInstIntegrationTest"]
    tasks.withType(Test) {
task -> = 'Tests'
    //exclude broken tests from all itest tasks
    if ("itest")){
            exclude '**/*${pattern}.*'

Problem is it looks like if “exclude” gets called before “include” the include filter wins. How can I get the “exclude” to execute after the “include”?

I know I could just put the exclude filter in every itest task declaration, but there are several reasons I’d rather not (I can explain if anyone cares).

thanks! phil

(Peter Niederwieser) #2

Excludes always wins over includes. Try ‘task.exclude …’ and make sure that the if-condition and patterns are correct.