Bug: Fail more gracefully when test class is missing Category
Status: Resolved | Priority: Minor | Resolution: Fixed
Created: 15/Jan/20 17:03

When a test class is missing a category, you might see an error such as:
{noformat}
[ERROR] Test mechanism  Time elapsed: 0.305 s  <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException: 0[ERROR] Test mechanism  Time elapsed: 0.102 s  <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException: 0[ERROR] Test mechanism  Time elapsed: 0.103 s  <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException: 0[ERROR] Test mechanism  Time elapsed: 0.102 s  <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException: 0[ERROR] Test mechanism  Time elapsed: 0.098 s  <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException: 0[ERROR] Test mechanism :: 0 {noformat}
You have to dig into the dump file to find out the actual error was:
{noformat}
org.apache.maven.surefire.testset.TestSetFailedException: Test mechanism :: 0
        at org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures(JUnit4RunListener.java:192)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:167)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:377)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:138)
        at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:465)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:451)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
        at org.apache.hadoop.hbase.HBaseClassTestRuleChecker.testStarted(HBaseClassTestRuleChecker.java:44)
        at org.junit.runner.notification.RunNotifier$5.notifyListener(RunNotifier.java:156)
        at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72)
        at org.junit.runner.notification.RunNotifier.fireTestStarted(RunNotifier.java:153)
        at org.apache.maven.surefire.common.junit4.Notifier.fireTestStarted(Notifier.java:100)
        at org.junit.internal.runners.model.EachTestNotifier.fireTestStarted(EachTestNotifier.java:42)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:364)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
        ... 4 more {noformat}
We can fix this up to get a proper exception thrown.