by hamstergene · 1y ago · 0 comments
It makes so much more sense this way:
- users don’t have to duplicate effort of writing more or less same mock/stub of the same library
- mock is forced to be up to date, because the library’s maintainers probably pay more attention to their release notes than you do
- no one knows the best choice of mocking approach/DSL than the library’s authors
- the adoption of inversion of control / dependency injection and comprehensive testing could be so much wider if writing a test didn’t require first solving an extra problem if how to mock something with complicated API and if it worth solving in the first place
// pull in some-library
implementation("some-library-coordinates")
// use its provided fixtures in tests
testImplementation(testFixtures("some-library-coordinates"))
wish it was more common in the ecosystem, but it seems most folks aren't aware of it.