Bug #1971
z2unit TestExecutor filtering out all tests when used with Parameterized runner
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
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());
}
Updated by Henning Blohm over 7 years ago
- Related to Bug #1946: Z2UnitTestRunner absorbs InitializationError from org.junit.runners.ParentRunner added
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.
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|da4b21d3a5e903346561adaeff3b0979c6620964.
Updated by Henning Blohm over 7 years ago
- Has duplicate Feature #1950: Z2Unit-TestExecutor should support Junit suites and Parameterized tests added