Closed translatenix closed 2 months ago
@translatenix Thanks for the catch. Which jqwik version(s) have you tried?
jqwik 1.8.4.
Can confirm as bug.
Workaround: Pull concrete classes outside of the abstract class' compilation scope:
public abstract class ListTest {
private final List<String> list;
public ListTest(List<String> list) {
this.list = list;
}
@AfterProperty
public void afterProperty() {
System.out.println("afterProperty");
}
@Example
public void example() {
System.out.println("example");
}
}
class ArrayListTest extends ListTest {
public ArrayListTest() {
super(new ArrayList<>());
}
}
class LinkedListTest extends ListTest {
public LinkedListTest() {
super(new LinkedList<>());
}
}
Fixed and released in 1.8.5-SNAPSHOT.
@translatenix Please re-open if fix doesn't work for you.
I'm using a subclassing pattern to test multiple implementations/configurations of a class.
This pattern works well with JUnit. But with jqwik, the
@AfterProperty
method gets called twice. Debugging this, it looks like a reflection problem related to subclassing (two@AfterProperty
methods are found).