Dear sir,
I have a few questions about KUnit, so I'm sending you an email.
I recently looked through the KUnit related documentation and sources of kernel-5.14, but couldn't find anything about Mock related APIs.
And it was confirmed that the following text was also found in the API item in the document.
"This file documents all of the standard testing API excluding mocking or mocking related features."
So my question is:
1. Where can I find the definition of mock-related API and how to use it?
Thank you
Best Regards
Dear sir,
I have a few questions about KUnit, so I'm sending you an email.
I recently looked through the KUnit related documentation and sources of kernel-5.14, but couldn't find anything about Mock related APIs.
And it was confirmed that the following text was also found in the API item in the document.
"This file documents all of the standard testing API excluding mocking or mocking related features."
So my question is:
1. Where can I find the definition of mock-related API and how to use it?
Thank you
Best Regards
--
You received this message because you are subscribed to the Google Groups "KUnit Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/cd3b5b3667a2651849ea365b87a8e6d5%40cweb008.nm.nfra.io.
Thank you for your quick reply.
I'm sorry, but I have one more question.
According to the answer, you said I should use fakes instead of mocks.
Actually, I'm trying to white-box test the device drivers(e.g. I2C, SPI, UART, etc.) using KUnit.
However, in the case of device driver, there are many parts that are processed by receving the return value from the hardware.
If google test is used, the hardware-dependent functions can be tested as mock_method(),
but in the case of KUnit, if mock cannot used, wouldn't it be impossible to write test code for hardware-dependent fuctions?
I'm not sure if it would make sense to use a fake for this.
In fact, I'm not sure if it is possible to use fakes to replace hardware-dependent function calls in code like google test;s mocks.
Please advise on this.
Thank you
Best Regards
-----Original Message-----
From: "Daniel Latypov"<dlat...@google.com>
To: "ddakjoa"<soos...@naver.com>;
Cc: <kuni...@googlegroups.com>;
Sent: 2021-10-27 (수) 00:40:05 (GMT+09:00)
Subject: Re: About the mock in KUnit
On Tue, Oct 26, 2021 at 2:24 AM ddakjoa <soos...@naver.com> wrote:
Dear sir,
I have a few questions about KUnit, so I'm sending you an email.
I recently looked through the KUnit related documentation and sources of kernel-5.14, but couldn't find anything about Mock related APIs.
And it was confirmed that the following text was also found in the API item in the document.
"This file documents all of the standard testing API excluding mocking or mocking related features."
I'm sorry, that statement in the documentation is incorrect.
I've been meaning to update that sentence but kept forgetting. I've sent a patch out to fix that.
(The history is that the original patchset included mocking, but it was removed and the documentation patches weren't updated).
So my question is:
1. Where can I find the definition of mock-related API and how to use it?
There is no API at the moment.
You'll need to implement your own mocking mechanism for now.
https://kunit.dev/mocking is currently the best resource we have with tips on how to do that.
Note: if possible, one should prefer fakes instead of mocks, see https://kunit.dev/mocking#fakes-versus-mocks
--
Thank you
Best Regards
You received this message because you are subscribed to the Google Groups "KUnit Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/cd3b5b3667a2651849ea365b87a8e6d5%40cweb008.nm.nfra.io.