简体   繁体   English

如何使用测试特定的类运行单元测试

[英]How to run unit tests with test specific class

I have a class that I need to replace with a dummy class when I'm running tests. 我有一个类,在运行测试时需要替换为虚拟类。 Is there a way to achieve this? 有没有办法做到这一点? I know product flavors offer something like this so I imagine this should be possible too. 我知道产品口味会提供这样的东西,所以我想这也应该是可能的。

You can use PowerMock . 您可以使用PowerMock It allows you to mock static methods and contructors to return mocked objects (and more). 它允许您模拟静态方法和构造函数以返回模拟对象(以及更多)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM