Skip to content

Can't use moduleOptions extension in custom test task #122

Open
@mizosoft

Description

@mizosoft

I'm having trouble running a custom test task on the classpath. The custom task is used to enable TestNG, which only a portion of the tests use. This is the relevant portion of my build file:

test {
  moduleOptions { // Ok
    runOnClasspath = true
  }

  useJUnitPlatform()
  testLogging {
    events = ['skipped', 'failed']
    showStandardStreams = true
  }
}

task tckTests(type: Test) {
  moduleOptions { // Causes problems
    runOnClasspath = true
  }

  useTestNG()
  testLogging {
    events = ['skipped', 'failed']
    showStandardStreams = true
  }
  mustRunAfter(':test')
}

Error:

Could not find method moduleOptions() for arguments [build_d4flzour41wmm2m64le5sxrq5$_run_closure4$_closure7@1825ba81] on task ':tckTests' of type org.gradle.api.tasks.testing.Test.

It also doesn't work when I instead try to configure tasks with type Test:

tasks.withType(Test) {
  moduleOptions {
    runOnClasspath = true
  }

  testLogging {
    events = ['skipped', 'failed']
    showStandardStreams = true
  }
}

Am I doing anything wrong or this is a limitation in the plugin ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions