However when using the nromal junit assertions, the failures are reported correctly.
import static org.junit.Assert.assertEquals;
Correctly shows up as a failure.
is there anything I can do to make sure spring Assert shows up as failure as well as the normal junit asserts ?
To clarify this
Assert.notNull(null开发者_运维百科);
Shows as an error in test report, and not a failure.
You are using the wrong Assert
class in your unit tests:
the
org.junit.Assert
class is for use in unit teststhe
org.springframework.util.Assert
class is for use in runtime code.
And the practical difference is that they throw different exceptions.
If your unit test is testing whether (say) your bean's afterPropertiesSet()
method is calling org.springframework.util.Assert
correctly, then this is not a simple JUnit style assertion. Rather, it is a test that IllegalArgumentException
is being thrown, and should be tested in the same way that you would test for (say) IOException
being thrown at the appropriate point.
精彩评论