AbstractTestResultAction<?> testResults = mock( AbstractTestResultAction.class );
when( testResults.getFailCount() ).thenReturn( 5 );
List<TestResult> failedTests = new ArrayList<TestResult>();
for(int i = 0; i < 5; i++) {
TestResult result = mock( TestResult.class );
when( result.isPassed() ).thenReturn( false );
when( result.getFullName() ).thenReturn( "hudson.plugins.emailext.ExtendedEmailPublisherTest" );
when( result.getDisplayName() ).thenReturn( "Test" + i );
when( result.getErrorDetails() ).thenReturn( StringUtils.leftPad( "", 3 * 1024, 'z' ) );
when( result.getErrorStackTrace() ).thenReturn( StringUtils.leftPad( "", 200, 'e' ) );
failedTests.add(result);
}
Mockito.<List<? extends TestResult>>when( testResults.getFailedTests() ).thenReturn( failedTests );
when( build.getAction(AbstractTestResultAction.class) ).thenReturn( testResults );