Describe the bug
When using ...extracting ("foo"), any exceptions thrown by property getter (i.e. getFoo()) is silently ignored if there is also a field named foo.
- assertj core version: 3.27.3
- java version: 27
- test framework version: verified with AssertJ called directly (without JUnit or something else)
- os (if relevant):
Test case reproducing the bug
Add a test case showing the bug that we can run
public static void main (String[] args)
{
assertThat (new Bean ()).extracting ("computed").isNull (); // This passes, even though getComputed() throws
assertThat (new Bean ().getComputed ()).isNull (); // But this fails as expected
}
public static class Bean
{
private String computed;
public String getComputed ()
{
if (computed == null) // Typical "compute once, then return the already computed value" pattern
computed = doCompute ();
return computed;
}
protected String doCompute ()
{
throw new RuntimeException ("failed to compute"); // But computation is buggy and throws an exception
}
}
Describe the bug
When using
...extracting ("foo"), any exceptions thrown by property getter (i.e.getFoo()) is silently ignored if there is also a field namedfoo.Test case reproducing the bug
Add a test case showing the bug that we can run