Bug #1946
Z2UnitTestRunner absorbs InitializationError from org.junit.runners.ParentRunner
Start date:
23.03.2016
Due date:
% Done:
100%
Estimated time:
2.00 h
origin:
Description
.h2 Problem
create a z2 unit test containing a private method with an @Test annotation.
org.junit.runners.ParentRunner will detect that this is an error and throws an InitializationError containing all violations:
// inside ParentRunner private void validate() throws InitializationError { List<Throwable> errors = new ArrayList<Throwable>(); collectInitializationErrors(errors); if (!errors.isEmpty()) { throw new InitializationError(errors); } }
Z2UnitTestRunner now catches all Exceptions and wraps them within a new InitializationError
so that the violations are hidden.
Suggestion¶
rewrite
public Z2UnitTestRunner(Class<?> klass) throws InitializationError { this.clz = klass; this.readConfig(); try { if (this.runWithClass!=Runner.class) { this.runWith = this.runWithClass.getConstructor(Class.class).newInstance(this.clz); } else { this.runWith = new BlockJUnit4ClassRunner(this.clz); } } catch (InitializationError e) { // InitializationError must not be wrapped! throw e; } catch (Exception e) { throw new InitializationError(e); } }
Related issues
Updated by Henning Blohm over 7 years ago
- Related to Improvement #1964: Better handling of non-serializable server-side throwables in Z2UnitTestRunner added
Updated by Henning Blohm over 7 years ago
- Related to Bug #1971: z2unit TestExecutor filtering out all tests when used with Parameterized runner added
Updated by Henning Blohm over 7 years ago
- Status changed from In Progress to Resolved
- % Done changed from 0 to 100
Applied in changeset z2-base:base|e48fe36861faf9c81725cc3a6576a37b9daf33e9.