Rabu, 28 Juli 2021

Difference between Stub and Mock object in Java Unit testing - JUnit

JUnit is the most popular framework for unit testing Java code. Unit testing is used to test a single programming unit e.g. a class or a method, in-fact many Java developers write unit tests on a per-method basis. Stub and Mock objects are two concepts that help during unit testing, they are not real objects but act like real objects for unit testing purposes. By the way, If you are absolutely a beginner in Java Unit testing then you can see this post to learn how to create the JUnit test in Eclipse. Coming back to Stubs and Mocks, One reason for using Stub and Mock object is the dependency of one unit into another. Since in real-world, the most unit doesn't work in isolation, they use dependent class and object to complete there task.

Lorem ipsum is simply dummy text of the printing and typesetting industry.

Comments


EmoticonEmoticon