Ram
Ram

Reputation: 55

Is object mocking and assumptions in Junit5 are same?

Recently I have gone through the blogs about assumption concept in JUnit5. And tried to correlate this concept with object mocking (with mockito or power mock). But I'm not yet concluded that both are same or not. Please can any one let me know whether assumption concept is replacement of mocking or not.

Thanks in advance.

Upvotes: 0

Views: 234

Answers (1)

Sam Brannen
Sam Brannen

Reputation: 31247

No, mocks and assumptions are not in any way related.

Mocks are used to replace real objects with so-called fakes, test doubles, spies, etc.

Whereas, Assumptions are a means to verify that an assumption is true before proceeding with the test. If an assumption fails (i.e., is false), the test will be immediately aborted but not marked as having failed.

For example, it is common to run certain test code only a certain operating system. The following demonstrates how to assume that the current OS is not MS Windows.

assumeFalse(System.getProperty("os.name").toLowerCase().contains("win"));

Regards,

Sam (core JUnit 5 committer)

Upvotes: 3

Related Questions