我可以以某种方式使用 AssertJ 断言 List 只有一个(子)类的实例吗?
public class A {}
public class B extends A {}
public class C extends A {}
@Test
public void test() {
List<A> list = new ArrayList<A>();
list.add(new B());
Assertions.assertThat(list).containsOnlyOnce(B.class);
}