How to mock ResourceBundle.getString()?

前端 未结 4 1057
盖世英雄少女心
盖世英雄少女心 2021-02-19 03:35

I\'m failing to mock ResourceBundle.getString().

This is my code:

ResourceBundle schemaBundle = Mockito.mock(ResourceBundle.class);
Mockito.         


        
4条回答
  •  面向向阳花
    2021-02-19 03:50

    I figured out a way to mock ResourceBundle by subclassing ResourceBundle.Control. My answer is here:

    https://stackoverflow.com/a/28640458/290254

    I prefer to avoid the dynamic bytecode rewriting (to remove final) of PowerMock, JMockit and friends, since Jacoco and other things seem to hate it.

提交回复
热议问题