NPE with excludeCategories and cucumber

When running cucumber tests, including any kind of “excludeCategories” will fail with the following NPE:

java.lang.NullPointerException
at org.junit.runner.Description.createSuiteDescription(Description.java:124)
at org.gradle.api.internal.tasks.testing.junit.CategoryFilter.shouldRun(CategoryFilter.java:47)
at org.junit.runners.ParentRunner.shouldRun(ParentRunner.java:434)
at org.junit.runners.ParentRunner.filter(ParentRunner.java:382)
at org.junit.runner.manipulation.Filter.apply(Filter.java:97)
at org.junit.runners.ParentRunner.filter(ParentRunner.java:384)
at org.junit.runner.manipulation.Filter.apply(Filter.java:97)
at org.junit.runners.ParentRunner.filter(ParentRunner.java:384)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:93)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:56)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:64)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50)

The cucumber test itself does not have to be excluded, it is sufficient with any kind of exclude not related to the testcase in question.

The enclosed sample project demonstrates the bug. Comment/uncomment excludeCategories to make this pass/fail

categoryBug.zip (1.8 KB)

Solmething like this should do the trick; I can’t get even get gradle core to compile, so any kind of serious contribution becomes impossible;

@Override public boolean shouldRun(final Description description) { Class<?> testClass = description.getTestClass(); Description desc = description.isSuite() || testClass == null ? null : Description.createSuiteDescription(testClass); return shouldRun(description, desc); }