Mocking static methods with Mockito

后端 未结 15 1096
Happy的楠姐
Happy的楠姐 2020-11-21 06:51

I\'ve written a factory to produce java.sql.Connection objects:

public class MySQLDatabaseConnectionFactory implements DatabaseConnectionFactory         


        
15条回答
  •  天涯浪人
    2020-11-21 07:34

    To mock static method you should use a Powermock look at: https://github.com/powermock/powermock/wiki/MockStatic. Mockito doesn't provide this functionality.

    You can read nice a article about mockito: http://refcardz.dzone.com/refcardz/mockito

提交回复
热议问题