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
{{ message }}
Repository navigation
Stubbing out a function called within S3 dispatch #43
I would now like to be able to call gen(x) is a test where foo() is stubbed out to avoid throwing the error. I assume this is currently not possible using mockery::stub()?
Then I switched to testthat 3e and found that with the current state of things I was not able to do the above using the advertised alternatives. Fine for me if you say this is not in-scope for 'mockery'. I'll close then.
@MichaelChirico I started to roll my own, as I was not happy with what {mockery} and {mockr} offered in terms of functionality: {mockthat}. Has worked fine for my own use so far, but I'm sure there are edge-cases, that will break things for my approach too. Happy to take feedback/issues/etc.
Activity
jimhester commentedon Dec 11, 2020
This limitation doesn't really seem to cause many issues in practice, you usually would mock the generic rather than a method.
nbenn commentedon Dec 11, 2020
Well ok, for whatever reason I was in the situation that I had written some tests using
testthat::with_mock()in a scenario likeThen I switched to testthat 3e and found that with the current state of things I was not able to do the above using the advertised alternatives. Fine for me if you say this is not in-scope for 'mockery'. I'll close then.
MichaelChirico commentedon Mar 9, 2022
I just ran into this myself. It's not clear how to use
mockeryto replacewith_mockhere:https://github.com/r-lib/lintr/blob/aafba478622c6f43c3fb329c69945c36a4d94b68/tests/testthat/test-ci.R#L47-L49
All of the following failed:
nbenn commentedon Mar 11, 2022
@MichaelChirico I started to roll my own, as I was not happy with what {mockery} and {mockr} offered in terms of functionality: {mockthat}. Has worked fine for my own use so far, but I'm sure there are edge-cases, that will break things for my approach too. Happy to take feedback/issues/etc.