You can conditionally add an exception based on the value of the property.
test {
if (project.hasProperty('excludeTests')) {
exclude project.property('excludeTests')
}
}
Then you can do something similar from the command line.
$ gradle -PexcludeTests=org.foo.MyTest build
source
share