Project

General

Profile

Bug #1971

z2unit TestExecutor filtering out all tests when used with Parameterized runner

Added by Henning Blohm over 7 years ago. Updated over 7 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
z2-base
Target version:
Start date:
12.04.2017
Due date:
% Done:

100%

Estimated time:
origin:

Description

in Testexecutor, the test description based filtering


// filter by description
r = r.filterWith(new Filter() {
  @Override
  public boolean shouldRun(Description d) {
    return description.equals(d) || children.containsKey(d);
  }
  @Override
  public String describe() {
    return description.toString();
  }
});


is removing all test methods.


Related issues

Related to z2-Environment - Bug #1946: Z2UnitTestRunner absorbs InitializationError from org.junit.runners.ParentRunnerResolved23.03.2016Henning Blohm

Actions
Has duplicate z2-Environment - Feature #1950: Z2Unit-TestExecutor should support Junit suites and Parameterized tests Resolved20.06.2016Henning Blohm

Actions
#1

Updated by Henning Blohm over 7 years ago

  • Description updated (diff)
#2

Updated by Henning Blohm over 7 years ago

Instead of the JSON de/serialization of the description object, we could use Java de/serialization as of Junit 4.12:


    private static byte[] toBytes(Serializable object) {
        try {
            try (ByteArrayOutputStream ba = new ByteArrayOutputStream()) {
                try (ObjectOutputStream oo = new ObjectOutputStream(ba)) {
                    oo.writeObject(object);
                }
                return ba.toByteArray();
            }
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }

    private static <C> C fromBytes(byte[] bytes, Class<C> clz) {
        try {
            try (ByteArrayInputStream ba = new ByteArrayInputStream(bytes)) {
                try (ObjectInputStream oi = new ObjectInputStream(ba) {
                    boolean first=true;
                    protected java.lang.Class<?> resolveClass(java.io.ObjectStreamClass desc) throws IOException ,ClassNotFoundException {
                        if (first) {
                            first = false;
                            // safeguard: First load must be the expected class 
                            if (!desc.getName().equals(clz.getName())) {
                                throw new IllegalArgumentException("Only class "+clz.getName()+" may be deserialized at this time");
                            }
                        }
                        return super.resolveClass(desc);
                    };
                }) {
                    return clz.cast(oi.readObject());
                }
            }
        } catch (ClassNotFoundException | IOException e) {
            throw new RuntimeException(e);
        }
    }

    private final static Logger logger = Logger.getLogger(JSONHelper.class.getName());
}

#3

Updated by Henning Blohm over 7 years ago

  • Related to Bug #1946: Z2UnitTestRunner absorbs InitializationError from org.junit.runners.ParentRunner added
#4

Updated by Henning Blohm over 7 years ago

  • Status changed from New to In Progress
#5

Updated by Henning Blohm over 7 years ago

The actual root cause is that we only filter max one level deep and Parameterized has a two-level deep tree.

#6

Updated by Henning Blohm over 7 years ago

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

Updated by Henning Blohm over 7 years ago

  • Has duplicate Feature #1950: Z2Unit-TestExecutor should support Junit suites and Parameterized tests added

Also available in: Atom PDF