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.
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.
- Description updated (diff)
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());
}
- Related to Bug #1946: Z2UnitTestRunner absorbs InitializationError from org.junit.runners.ParentRunner added
- Status changed from New to In Progress
The actual root cause is that we only filter max one level deep and Parameterized has a two-level deep tree.
- Status changed from In Progress to Resolved
- % Done changed from 0 to 100
- Has duplicate Feature #1950: Z2Unit-TestExecutor should support Junit suites and Parameterized tests added
Also available in: Atom
PDF