Project

General

Profile

Bug #1946

Z2UnitTestRunner absorbs InitializationError from org.junit.runners.ParentRunner

Added by Udo Offermann about 8 years ago. Updated about 7 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
z2-base
Target version:
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

Related to z2-Environment - Improvement #1964: Better handling of non-serializable server-side throwables in Z2UnitTestRunnerResolved27.01.2017Henning Blohm

Actions
Related to z2-Environment - Bug #1971: z2unit TestExecutor filtering out all tests when used with Parameterized runnerResolved12.04.2017Henning Blohm

Actions

Also available in: Atom PDF