You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/09/28 01:37:55 UTC

[GitHub] [incubator-shardingsphere] sluk3r opened a new issue #3149: help for mock static method when unit test

sluk3r opened a new issue #3149: help for mock static method when unit test
URL: https://github.com/apache/incubator-shardingsphere/issues/3149
 
 
   Hi, all. would you help me with that problem: how can I mock static method when unit test. 
   
   I try to unit test the following code: 
   
   ```java 
   public LogicSchema(final String name, final Map<String, YamlDataSourceParameter> dataSources) {
           this.name = name;
           parseEngine = SQLParseEngineFactory.getSQLParseEngine(LogicSchemas.getInstance().getDatabaseType());
           backendDataSource = new JDBCBackendDataSource(dataSources);
           ShardingOrchestrationEventBus.getInstance().register(this);
   }
   ```
   
   
   And find that there are two static method invocation, mockito doesn't support static method mock. 
   
   after some google, I found Powermock can mock static method easily, example is: https://java2blog.com/mockito-mock-static-method/
   
   
   So, should I import Powermock into ss? Or is there some mature  experience  for mock static method? 
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services