ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Man, CLSA" <jason....@clsa.com>
Subject Adopting mock framework (ex. Mockito) for unit tests
Date Tue, 16 Jan 2018 10:13:24 GMT
Hi Igniters,

I'd like to discuss the topic of adopting a mock framework such as Mockito into Ignite's project
for writing unit tests.

Here's a simple article that illustrate why using a mock object for testing is necessary,
and why using a framework is better than doing it yourself:
https://zeroturnaround.com/rebellabs/how-to-mock-up-your-unit-test-environment-to-create-alternate-realities/

Here's Mokito's website which also illustrate the Why and How:
http://site.mockito.org/

Then, here's my PR for one of the bug fixes I'm trying to fix in Ignite that prompted me to
use mocks:
https://github.com/apache/ignite/pull/3088/files

In the case of my unit test, not using a mocking framework will be difficult to test certain
negative behaviour of Cassandra.  On the other hand, manually mocking the objects (instead
of using a framework) will result in hundreds of lines of boiler plate code.  Or in some cases,
it's ugly to mock an object where it has a package-private constructor instead of a public
one. (you'd have to put your mock object in the same package...)

Overall, I think introducing a mocking framework can help us write unit tests that have better
coverage of code, especially mocking behaviour of external dependencies (such as Cassandra).

What do you guys think?

Regards,
Jason

The content of this communication is intended for the recipient and is subject to CLSA Legal
and Regulatory Notices.
These can be viewed at https://www.clsa.com/disclaimer.html or sent to you upon request.
Please consider before printing. CLSA is ISO14001 certified and committed to reducing its
impact on the environment.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message