The idea is that your source code no longer has to be changed. You don't test your source-code, you test a modified copy that allows mocking.
How so?
All modules imported via mockImport get read in, modified as they would be in mocker.nim (so that the exported procs get the mockable pragma attached) and that modified copy gets written to "testDirectory".
You then import that modified copy in the test.
All modules imported via testImport get read in, modified in the sense that their imports no longer point to the source code, but instead to the modified copies and that modified testImport-ed module gets also written to "testDirectory".
You then import that modified copy in the test.
Tests get written for the procs of the testImport-ed module. This means you are no longer actually testing source-code, but near identical code, that should be similar enough.
If that isn't good enough for the user though, they can instead just use mockable themselves in their source code and work with that.
The idea is that your source code no longer has to be changed. You don't test your source-code, you test a modified copy that allows mocking.
How so?
All modules imported via
mockImportget read in, modified as they would be inmocker.nim(so that the exported procs get the mockable pragma attached) and that modified copy gets written to "testDirectory".You then import that modified copy in the test.
All modules imported via
testImportget read in, modified in the sense that their imports no longer point to the source code, but instead to the modified copies and that modifiedtestImport-ed module gets also written to "testDirectory".You then import that modified copy in the test.
Tests get written for the procs of the testImport-ed module. This means you are no longer actually testing source-code, but near identical code, that should be similar enough.
If that isn't good enough for the user though, they can instead just use mockable themselves in their source code and work with that.