You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
counterfeiter fakes include a line at the bottom which assigns a pointer to the fake to a variable declared as type of interface being mocked. This is a great way to ensure that the counterfeit actually implements the specified interface so that the compiler will generate an error when the interface changes, but it means that you cannot implement a test that depends on the counterfeit implementation within the package itself, because it forces a dependency on that package into packagefakes package.
This means that every time we run go generate, we must also run a script which strips that line out of each generated file. There should be a command line option to skip adding that line to the counterfeit, or which specifies the file to add it to. If I want to detect that the interface is no longer satisfied, I can add such an assignment myself, rather than having the code generator break all test code that adheres to the common pattern of putting tests in the same package as the code being tested (in order to gain access to non-exported fields and methods, which can greatly simplify testing). But it would be even better to have the generator add the line to a specified file so that we can generate those checks in the package being tested rather than in the packagefakes package where it causes an import cycle.
The text was updated successfully, but these errors were encountered:
counterfeiter fakes include a line at the bottom which assigns a pointer to the fake to a variable declared as type of interface being mocked. This is a great way to ensure that the counterfeit actually implements the specified interface so that the compiler will generate an error when the interface changes, but it means that you cannot implement a test that depends on the counterfeit implementation within the package itself, because it forces a dependency on that package into packagefakes package.
This means that every time we run
go generate
, we must also run a script which strips that line out of each generated file. There should be a command line option to skip adding that line to the counterfeit, or which specifies the file to add it to. If I want to detect that the interface is no longer satisfied, I can add such an assignment myself, rather than having the code generator break all test code that adheres to the common pattern of putting tests in the same package as the code being tested (in order to gain access to non-exported fields and methods, which can greatly simplify testing). But it would be even better to have the generator add the line to a specified file so that we can generate those checks in the package being tested rather than in the packagefakes package where it causes an import cycle.The text was updated successfully, but these errors were encountered: