Skip to content
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

单独取消mock的疑问 #30

Open
KyleDeng opened this issue Jan 7, 2022 · 1 comment
Open

单独取消mock的疑问 #30

KyleDeng opened this issue Jan 7, 2022 · 1 comment

Comments

@KyleDeng
Copy link

KyleDeng commented Jan 7, 2022

在mock过程中增加了许多接口的mock,但是无法单独取消某个接口mock,
使用verify()后会全部取消。
请问有没有办法在verify后,保留之前的mock内容?

@sinojelly
Copy link
Owner

为啥 verify 后还要保留mock呢?
是不是测试用例有点复杂?
一般,建议用例写得简单,这样比较容易确定用例的正确性,用它来测试,才能保证产品代码的正确性。
一般也建议用例之间不干扰,所以一个用例运行完,取消该用户运行中的mock。

另外,如果某些mock内容,是每个用例都需要运行的,则可以放到 SetUp 里面。
这样每个用例运行,都会自动把SetUp中的mock加上。是不是也能满足你的场景?

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

No branches or pull requests

2 participants