Project

General

Profile

Bug #1946

Z2UnitTestRunner absorbs InitializationError from org.junit.runners.ParentRunner

Added by Udo Offermann over 8 years ago. Updated over 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
#1

Updated by Udo Offermann over 8 years ago

  • Description updated (diff)
#2

Updated by Udo Offermann over 8 years ago

  • Description updated (diff)
#3

Updated by Henning Blohm over 8 years ago

  • Target version set to 2.5
#4

Updated by Henning Blohm over 7 years ago

  • Related to Improvement #1964: Better handling of non-serializable server-side throwables in Z2UnitTestRunner added
#5

Updated by Henning Blohm over 7 years ago

  • Related to Bug #1971: z2unit TestExecutor filtering out all tests when used with Parameterized runner added
#6

Updated by Henning Blohm over 7 years ago

  • Status changed from New to In Progress
#7

Updated by Henning Blohm over 7 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF