Skip to content

Test a function with a passed in struct that can be mocked #478

Answered by asomers
Ben-PH asked this question in Questions
Discussion options

You must be logged in to vote

Then that's your problem. Because when you build a crate in test mode, its dependencies are not build in test mode. So what you want to do is probably to create a testing feature for the massa_network_exports crate and export mock objects when that feature is set, not just when test is set. Then in your consuming create, ensure that you use the dependency's testing feature whenever you build in test mode. Or, combine the two crates into one.

Replies: 5 comments 26 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@Ben-PH
Comment options

@asomers
Comment options

@Ben-PH
Comment options

@asomers
Comment options

@Ben-PH
Comment options

Comment options

You must be logged in to vote
2 replies
@Ben-PH
Comment options

@Ben-PH
Comment options

Comment options

You must be logged in to vote
3 replies
@Ben-PH
Comment options

@Ben-PH
Comment options

@asomers
Comment options

Comment options

You must be logged in to vote
14 replies
@Ben-PH
Comment options

@Ben-PH
Comment options

@asomers
Comment options

Answer selected by Ben-PH
@Ben-PH
Comment options

@zephod77
Comment options

@asomers
Comment options

@zephod77
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants