Here is how I got the test passing the static method:
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(Cucumber.class)
@PowerMockIgnore( { "javax.management.*" })
@PrepareForTest({FileUtils.class})
@CucumberOptions(
plugin = {"pretty", "html:target/build/reports/tests/test", "junit:/Users/arnout/dev/buildserver.git/build/test-results/test/cucumber.xml", "json:/Users/arnout/dev/buildserver.git/build/test-results/test/cucumber.jsonâ},
dryRun = false,
strict = false,
features = {"/Users/arnout/dev/buildserver.git/soton-test/resources/features"},
snippets = SnippetType.CAMELCASE
)
public class RelatedNewsFeatureTest { }
I have then created a Helper class that does all the digging into the implementation classes.
The helper class has this instance field:
mockStatic(FileUtils.class);
Then I run
when(FileUtils.recursiveFileList(customFileDal, dirPath)).thenReturn(mockPageList);
I use Gradle for dependencies. Here is the list I got:
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
testCompile group: 'org.powermock', name: 'powermock-core', version: '1.7.4'
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.7.4'
testCompile group: 'org.powermock', name: 'powermock-api-mockito', version: '1.7.4'
testCompile group: 'org.powermock', name: 'powermock-module-junit4-rule', version: '1.7.4'
testCompile group: 'org.powermock', name: 'powermock-classloading-base', version: '1.7.4'
testCompile group: 'org.powermock', name: 'powermock-classloading-objenesis', version: '1.7.4'