Using Assume.assumeTrue or Assert.assertTrue when tests end?

I use JUnit 4.12, and this is my real understanding of the following APIs that I often use:

  • acceptTrue: if the expression evaluates to false, the test will stop and be ignored
  • assertTrue: if the condition is false, throws an AssertionError
  • assertEquals: if they are not equal, AssertionError is thrown with this message
  • assertNotNull: if it is NULL, throws an AssertionError

However, I cannot get clarity regarding a few things:

  • My understanding is that only acceptTrue tests will complete, but the assert definition itself is that the program should exit when the statement evaluates to false
  • when the test throws an AssertionError, does it exit the test case or continue with the remaining steps?
  • Can tests be considered passed even if they throw an AssertionError or are the tests considered unsuccessful?
0
source share
1 answer
  • assumeTruemeans that the test should not be performed. This does not mean that your code is broken, and most runners will consider this test as “ignored”

  • An AssertionErrormeans the test did not work. No additional steps will be performed in this test case (single method). It would be pointless to do this as the test has already failed

  • . , , . assertNull assertNotNull

+1

Source: https://habr.com/ru/post/1679626/


All Articles