Skip to content

Commit

Permalink
Deprecating AbstractBuild.getTestResultAction.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Jul 22, 2014
1 parent 26b1e1b commit f8f1af2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Expand Up @@ -56,7 +56,7 @@ public void testGetContent_whenAllTestsPassedShouldGiveMeaningfulMessage()
AbstractTestResultAction testResults = mock( AbstractTestResultAction.class );
when( testResults.getFailCount() ).thenReturn( 0 );

when( build.getTestResultAction() ).thenReturn( testResults );
when( build.getAction(AbstractTestResultAction.class) ).thenReturn( testResults );

String content = failedTestContent.evaluate( build, listener, FailedTestsContent.MACRO_NAME );

Expand All @@ -69,7 +69,7 @@ public void testGetContent_whenSomeTestsFailedShouldGiveMeaningfulMessage()
AbstractTestResultAction<?> testResults = mock( AbstractTestResultAction.class );
when( testResults.getFailCount() ).thenReturn( 123 );

when( build.getTestResultAction() ).thenReturn( testResults );
when( build.getAction(AbstractTestResultAction.class) ).thenReturn( testResults );

failedTestContent.maxTests = 0;
String content = failedTestContent.evaluate( build, listener, FailedTestsContent.MACRO_NAME );
Expand All @@ -95,7 +95,7 @@ public void testGetContent_withMessage_withStack()
}

Mockito.<List<? extends TestResult>>when( testResults.getFailedTests() ).thenReturn( failedTests );
when( build.getTestResultAction() ).thenReturn( testResults );
when( build.getAction(AbstractTestResultAction.class) ).thenReturn( testResults );

failedTestContent.maxTests = 2;
failedTestContent.showMessage = true;
Expand Down Expand Up @@ -126,7 +126,7 @@ public void testGetContent_noMessage_withStack()
failedTests.add(result);
}
Mockito.<List<? extends TestResult>>when( testResults.getFailedTests() ).thenReturn( failedTests );
when( build.getTestResultAction() ).thenReturn( testResults );
when( build.getAction(AbstractTestResultAction.class) ).thenReturn( testResults );

failedTestContent.maxTests = 2;
failedTestContent.showMessage = false;
Expand Down Expand Up @@ -157,7 +157,7 @@ public void testGetContent_withMessage_noStack()
failedTests.add(result);
}
Mockito.<List<? extends TestResult>>when( testResults.getFailedTests() ).thenReturn( failedTests );
when( build.getTestResultAction() ).thenReturn( testResults );
when( build.getAction(AbstractTestResultAction.class) ).thenReturn( testResults );

failedTestContent.maxTests = 2;
failedTestContent.showMessage = true;
Expand Down Expand Up @@ -188,7 +188,7 @@ public void testGetContent_noMessage_noStack()
failedTests.add(result);
}
Mockito.<List<? extends TestResult>>when( testResults.getFailedTests() ).thenReturn( failedTests );
when( build.getTestResultAction() ).thenReturn( testResults );
when( build.getAction(AbstractTestResultAction.class) ).thenReturn( testResults );

failedTestContent.maxTests = 2;
failedTestContent.showMessage = false;
Expand Down Expand Up @@ -220,7 +220,7 @@ public void testGetContent_whenContentLargerThanMaxLengthShouldTruncate()
}

Mockito.<List<? extends TestResult>>when( testResults.getFailedTests() ).thenReturn( failedTests );
when( build.getTestResultAction() ).thenReturn( testResults );
when( build.getAction(AbstractTestResultAction.class) ).thenReturn( testResults );

failedTestContent.maxLength = 10;
String content = failedTestContent.evaluate( build, listener, FailedTestsContent.MACRO_NAME );
Expand Down
Expand Up @@ -47,7 +47,7 @@ public void testGetContent() throws Exception {
when(results.getTotalCount() - results.getFailCount() - results.getSkipCount()).thenReturn(2);
when(results.getFailCount()).thenReturn(2);
when(results.getSkipCount()).thenReturn(1);
when(build.getTestResultAction()).thenReturn(results);
when(build.getAction(AbstractTestResultAction.class)).thenReturn(results);

assertEquals("5", target.evaluate(build, listener, TestCountsContent.MACRO_NAME));
target.var = "total";
Expand Down
Expand Up @@ -39,6 +39,7 @@
import hudson.tasks.Mailer;
import hudson.tasks.junit.CaseResult;
import hudson.tasks.junit.TestResultAction;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.util.StreamTaskListener;
import java.nio.charset.Charset;
import java.util.ArrayList;
Expand Down Expand Up @@ -256,6 +257,6 @@ private static void addMockTestResultAction(final AbstractBuild build, final Abs
final TestResultAction testResultAction = PowerMockito.mock(TestResultAction.class);
PowerMockito.when(testResultAction.getFailedTests()).thenReturn(failedTests);
PowerMockito.when(testResultAction.getFailCount()).thenReturn(failedTests.size());
PowerMockito.when(build.getTestResultAction()).thenReturn(testResultAction);
PowerMockito.when(build.getAction(AbstractTestResultAction.class)).thenReturn(testResultAction);
}
}

0 comments on commit f8f1af2

Please sign in to comment.