maven
    注意powermock-api-mockito 2.0以上给项目重新起了个名字。

    1. <dependency>
    2. <groupId>org.powermock</groupId>
    3. <artifactId>powermock-module-junit4</artifactId>
    4. <version>2.0.9</version>
    5. </dependency>
    6. <dependency>
    7. <groupId>org.powermock</groupId>
    8. <artifactId>powermock-api-mockito2</artifactId>
    9. <version>2.0.9</version>
    10. </dependency>
    1. @RunWith(PowerMockRunner.class)
    2. @PrepareForTest({RedisKeyUtil.class})
    3. PowerMockito.mockStatic(System.class);
    4. PowerMockito.when(System.getenv("123")).thenReturn("123");