-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate x/mock, transition integration tests to use simapp #4875
Closed
17 of 20 tasks
Labels
Comments
This was referenced Aug 8, 2019
Closed
Merged
4 tasks
This was referenced Aug 12, 2019
Merged
Merged
Merged
4 tasks
Update: However, we still have to update and fix the ad-hoc logic in the keeper unit tests to also use |
11 tasks
This was referenced Feb 28, 2020
11 tasks
12 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
Deprecate (eventually remove) usage/reliance on
x/mock
in favor of usingSimApp
for integration tests.Problem Definition
Integration tests have been a pain point for import cycles. To test a modules integration we need access to many of the other modules. There are a few approaches for this.
One is to mock the usage of the other modules. After a lot of deliberation, I don't think this is an optimal approach. It adds the possibility of more bugs when trying to mock a module, and requires maintenance as changes are made. In fact the current mock module is quite out of date and doesn't even have a module manager.
Furthermore,
x/mock
is only used by about half of the modules and the rest of the modules have redundant code incommon_test/test_common
files.Proposal
Instead, I think we should draw a clear line between unit and integration tests such that they are approached in two different standardized manners.
Unit tests will continue to be how they are currently done now, i.e. they don't need to import outside modules, have the same package name as non-testing code, and ideally are readable (table tests).
Integration tests however will have two main changes.
SimApp
(thanks @fedekunze for working to refactor simulation!!)pkgname_test
(ex:keeper_test
as opposed to justkeeper
)Justification:
Our integration is very tangled up and trying to work around this will probably cause even more complexity. Instead, lets make the process much simpler for testing. The go std lib also runs into this issue as well; for example, the
testing
pkg uses thestrings
pkg and thestrings
pkg needs to usetesting
. So the test file has a different package name so this dependency ontesting
is not exported withstrings
during testing compilation. You can see that hereSince no package should be importing a package ending in
_test
we can use simapp which imports everything we may need.We can add a guide that makes the two routes of testing very clear.
Unit tests -> don't import, make readable
Integration tests -> change package name, import simapp, make keeper/handler calls
References:
mock
? #1555Modules to modify:
For Admin Use
The text was updated successfully, but these errors were encountered: