maxbrunsfeld / counterfeiter

A tool for generating self-contained, type-safe test doubles in go
MIT License
931 stars 90 forks source link

Import cycle is not allowed in test #262

Open ikolomiyets opened 9 months ago

ikolomiyets commented 9 months ago

I have encountered the issue which I believe was reported and discussed numerous times. The problem occurs when interface that is getting mocked is residing in the same package where it is getting used. Fake implementations are generated perfectly but when I am trying to run the tests I am getting the following error:

    imports github.com/ikolomiyets/test-project/internal/controllers/controllersfakes
    imports github.com/ikolomiyets/test-project/internal/controllers: import cycle not allowed in test

It would be great to have a separate mode for this kind of mocks, so the fake implementations are generated into the same package into the file with _test.go suffix.