Skip to content

Commit

Permalink
[JENKINS-27240] Fix tests, remove unused import.
Browse files Browse the repository at this point in the history
Specifically fixing a few injections of BuildListener -> TaskListener,
and making sure the workflow tests don't fail on old results.
  • Loading branch information
abayer committed Jan 13, 2016
1 parent f0991d7 commit 23e56ca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Expand Up @@ -25,7 +25,6 @@
package org.jenkinsci.plugins.xunit.service;

import com.google.inject.Inject;
import hudson.model.BuildListener;
import hudson.model.TaskListener;

import java.io.Serializable;
Expand Down
Expand Up @@ -50,7 +50,7 @@ public void xunitBuilderWorkflowStepTest() throws Exception {
WorkflowJob job = getBaseJob("builder");
job.setDefinition(new CpsFlowDefinition(""
+ "node {\n"
+ " step([$class: 'XUnitBuilder', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '1'], [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']], tools: [[$class: 'GoogleTestType', deleteOutputFiles: false, failIfNotNew: true, pattern: 'input.xml', skipNoTestFiles: false, stopProcessingIfError: true]]])\n"
+ " step([$class: 'XUnitBuilder', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '1'], [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']], tools: [[$class: 'GoogleTestType', deleteOutputFiles: false, failIfNotNew: false, pattern: 'input.xml', skipNoTestFiles: false, stopProcessingIfError: true]]])\n"
+ "}"));

jenkinsRule.assertBuildStatus(Result.UNSTABLE, job.scheduleBuild2(0).get());
Expand All @@ -61,7 +61,7 @@ public void xunitPublisherWorkflowStepTest() throws Exception {
WorkflowJob job = getBaseJob("publisher");
job.setDefinition(new CpsFlowDefinition(""
+ "node {\n"
+ " step([$class: 'XUnitPublisher', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '1'], [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']], tools: [[$class: 'GoogleTestType', deleteOutputFiles: false, failIfNotNew: true, pattern: 'input.xml', skipNoTestFiles: false, stopProcessingIfError: true]]])\n"
+ " step([$class: 'XUnitPublisher', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '1'], [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']], tools: [[$class: 'GoogleTestType', deleteOutputFiles: false, failIfNotNew: false, pattern: 'input.xml', skipNoTestFiles: false, stopProcessingIfError: true]]])\n"
+ "}"));

jenkinsRule.assertBuildStatus(Result.UNSTABLE, job.scheduleBuild2(0).get());
Expand Down
Expand Up @@ -4,7 +4,7 @@
import com.google.inject.Guice;
import com.google.inject.Singleton;
import hudson.Util;
import hudson.model.BuildListener;
import hudson.model.TaskListener;
import org.jenkinsci.lib.dtkit.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.model.InputMetricType;
import org.jenkinsci.lib.dtkit.model.InputMetricXSL;
Expand Down Expand Up @@ -92,13 +92,13 @@ public TestTypeDescriptor<? extends TestType> getDescriptor() {

@BeforeClass
public static void init() {
final BuildListener listenerMock = mock(BuildListener.class);
final TaskListener listenerMock = mock(TaskListener.class);
when(listenerMock.getLogger()).thenReturn(new PrintStream(new ByteArrayOutputStream()));
xUnitReportProcessorService = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(XUnitLog.class).in(Singleton.class);
bind(BuildListener.class).toInstance(listenerMock);
bind(TaskListener.class).toInstance(listenerMock);
}
}).getInstance(XUnitReportProcessorService.class);

Expand Down
Expand Up @@ -3,7 +3,7 @@
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Stage;
import hudson.model.BuildListener;
import hudson.model.TaskListener;
import hudson.remoting.VirtualChannel;
import org.jenkinsci.lib.dtkit.model.InputMetricType;
import org.jenkinsci.lib.dtkit.model.InputMetricXSL;
Expand All @@ -30,7 +30,7 @@ public class XUnitTransformerTest {

@Mock
@SuppressWarnings("unused")
private BuildListener buildListenerMock;
private TaskListener buildListenerMock;

@Mock
@SuppressWarnings("unused")
Expand Down Expand Up @@ -64,7 +64,7 @@ public void beforeTest() throws IOException {
xUnitTransformer = Guice.createInjector(Stage.DEVELOPMENT, new AbstractModule() {
@Override
protected void configure() {
bind(BuildListener.class).toInstance(buildListenerMock);
bind(TaskListener.class).toInstance(buildListenerMock);
bind(XUnitToolInfo.class).toInstance(xUnitToolInfoMock);
bind(XUnitConversionService.class).toInstance(xUnitConversionServiceMock);
bind(XUnitValidationService.class).toInstance(xUnitValidationServiceMock);
Expand Down

0 comments on commit 23e56ca

Please sign in to comment.