From the stack trace, you can see this exception isn't being thrown in the testName()
method: it's being thrown by tests.BranchTests.cleanUp
, which is presumably a separate method run before or after your real test.
JUnit's expected
won't cover exceptions thrown during these phases. Either ensure these failures don't happen here, or catch and ignore them.