Suppose vs claim in JUnit tests

I have read that assumethere will be to run the test, if the assumption is not satisfied, but I'm not sure of the logic of when to place assertvs assume.

For example: should any resource load check be done with assume?

When should you use assumeover assert?

(Note: I'm looking for the right design when using one over the other)

+4
source share
3 answers

assume, , . " " , , , , .

assert , - .

, , :

  • ,
  • , ,
  • - ,

, :

  • , ( , ),
  • , ( , , , , .)
+4

Assert JUnit, JUnit . JUnit . , , . , , True, False Null, .

, assert:

assert<something>("Failure Message String", <condition to be tested>);

: , , , JUnit , .

Asserts and Assumes , . , Assert , Assume . , , , .

Assumes: , , , , Hamcrest. "", Hamcrest .

https://objectcomputing.com/resources/publications/sett/march-2014-junit-not-just-another-pretty-assert/

, , , Linux: Assume.assumeFalse(System.getProperty("os.name").contains("Linux"));
Assert .

+3

javadoc :

, , . , , .

: assert, , . , .

Suppose ... you don’t know exactly what happened.

+1
source

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


All Articles