Skip to content
Permalink
Browse files

[JENKINS-37611] Add "@symbol" annotation to xunit and parameters

Add @symbol annotation to publisher, thresholds and test type to make pipeline readable. Add pipeline unit test that works with Jenkins 1.x
Update parent pom to latest 3.9
  • Loading branch information
nfalco79 committed May 2, 2018
1 parent fadb799 commit e52107f6e3b88373f02c23b9c98ba1c263f5d85f
Showing with 291 additions and 74 deletions.
  1. +73 −35 pom.xml
  2. +2 −7 src/main/java/org/jenkinsci/plugins/xunit/XUnitBuilder.java
  3. +6 −8 src/main/java/org/jenkinsci/plugins/xunit/XUnitPublisher.java
  4. +3 −0 src/main/java/org/jenkinsci/plugins/xunit/threshold/FailedThresholdDescriptor.java
  5. +3 −0 src/main/java/org/jenkinsci/plugins/xunit/threshold/SkippedThresholdDescriptor.java
  6. +11 −1 src/main/java/org/jenkinsci/plugins/xunit/types/AUnitJunitHudsonTestType.java
  7. +9 −1 src/main/java/org/jenkinsci/plugins/xunit/types/BoostTestJunitHudsonTestType.java
  8. +10 −1 src/main/java/org/jenkinsci/plugins/xunit/types/CTestType.java
  9. +11 −1 src/main/java/org/jenkinsci/plugins/xunit/types/CUnitJunitHudsonTestType.java
  10. +4 −1 src/main/java/org/jenkinsci/plugins/xunit/types/CheckType.java
  11. +9 −1 src/main/java/org/jenkinsci/plugins/xunit/types/CppTestJunitHudsonTestType.java
  12. +13 −1 src/main/java/org/jenkinsci/plugins/xunit/types/CppUnitJunitHudsonTestType.java
  13. +2 −0 src/main/java/org/jenkinsci/plugins/xunit/types/CustomType.java
  14. +11 −1 src/main/java/org/jenkinsci/plugins/xunit/types/EmbUnitType.java
  15. +10 −1 src/main/java/org/jenkinsci/plugins/xunit/types/FPCUnitJunitHudsonTestType.java
  16. +9 −1 src/main/java/org/jenkinsci/plugins/xunit/types/GTesterJunitHudsonTestType.java
  17. +7 −1 src/main/java/org/jenkinsci/plugins/xunit/types/GoogleTestType.java
  18. +8 −1 src/main/java/org/jenkinsci/plugins/xunit/types/JUnitType.java
  19. +8 −1 src/main/java/org/jenkinsci/plugins/xunit/types/MSTestJunitHudsonTestType.java
  20. +8 −1 src/main/java/org/jenkinsci/plugins/xunit/types/MbUnitType.java
  21. +4 −1 src/main/java/org/jenkinsci/plugins/xunit/types/NUnit3TestType.java
  22. +8 −1 src/main/java/org/jenkinsci/plugins/xunit/types/NUnitJunitHudsonTestType.java
  23. +9 −1 src/main/java/org/jenkinsci/plugins/xunit/types/PHPUnitJunitHudsonTestType.java
  24. +1 −1 src/main/java/org/jenkinsci/plugins/xunit/types/QTestLibInputMetric.java
  25. +10 −1 src/main/java/org/jenkinsci/plugins/xunit/types/QTestLibType.java
  26. +4 −1 src/main/java/org/jenkinsci/plugins/xunit/types/UnitTestJunitHudsonTestType.java
  27. +10 −1 src/main/java/org/jenkinsci/plugins/xunit/types/ValgrindJunitHudsonTestType.java
  28. +11 −1 src/main/java/org/jenkinsci/plugins/xunit/types/XUnitDotNetTestType.java
  29. +17 −2 src/test/java/org/jenkinsci/plugins/xunit/XUnitWorkflowTest.java
108 pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.37</version>
<version>3.9</version>
</parent>

<artifactId>xunit</artifactId>
@@ -41,12 +41,12 @@

<properties>
<dtkit.frmk.version>2.0.0</dtkit.frmk.version>
<xerces.version>2.9.1</xerces.version>
<saxon.version>9.1.0.8</saxon.version>
<dry.run.version>0.1</dry.run.version>
<xmlunit.version>1.6</xmlunit.version>
<mockito.version>2.17.0</mockito.version>
<jenkins.version>1.651.3</jenkins.version>
<java.level>7</java.level>
</properties>

<repositories>
@@ -63,6 +63,26 @@
</pluginRepository>
</pluginRepositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>annotation-indexer</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.lib.dtkit</groupId>
@@ -75,7 +95,6 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.jenkins-ci.lib.dtkit</groupId>
<artifactId>dtkit-metrics-util</artifactId>
@@ -87,7 +106,6 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.jenkins-ci.lib.dtkit</groupId>
<artifactId>dtkit-metrics-hudson-api</artifactId>
@@ -100,34 +118,17 @@
<version>${dry.run.version}</version>
</dependency>


<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>${saxon.version}</version>
</dependency>

<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>${saxon.version}</version>
<classifier>s9api</classifier>
</dependency>

<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
@@ -142,12 +143,49 @@
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-aggregator</artifactId>
<version>1.7</version>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.13</version>
</dependency>

<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>

<!-- dependencies to get pipeline work with Jenkins 1.x -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.32</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>2.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>2.6</version>
<scope>test</scope>
</dependency>
</dependencies>

<scm>
@@ -157,17 +195,17 @@
</scm>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
@@ -62,15 +62,10 @@
private int thresholdMode;
private ExtraConfiguration extraConfiguration;

public XUnitBuilder(@CheckForNull TestType[] tools, @CheckForNull XUnitThreshold[] thresholds) {
this.types = (tools != null ? Arrays.copyOf(tools, tools.length) : new TestType[0]);
this.thresholds = (thresholds != null ? Arrays.copyOf(thresholds, thresholds.length) : new XUnitThreshold[0]);
this.thresholdMode = 1;
}

@DataBoundConstructor
public XUnitBuilder(@CheckForNull TestType[] tools, @CheckForNull XUnitThreshold[] thresholds, int thresholdMode, @CheckForNull String testTimeMargin) {
this(tools, thresholds);
this.types = (tools != null ? Arrays.copyOf(tools, tools.length) : new TestType[0]);
this.thresholds = (thresholds != null ? Arrays.copyOf(thresholds, thresholds.length) : new XUnitThreshold[0]);
this.thresholdMode = thresholdMode;
long longTestTimeMargin = XUnitDefaultValues.TEST_REPORT_TIME_MARGING;
if (testTimeMargin != null && testTimeMargin.trim().length() != 0) {
@@ -30,6 +30,7 @@

import javax.annotation.CheckForNull;

import org.jenkinsci.Symbol;
import org.jenkinsci.lib.dryrun.DryRun;
import org.jenkinsci.lib.dtkit.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType;
@@ -39,6 +40,8 @@
import org.jenkinsci.plugins.xunit.threshold.XUnitThresholdDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;

import com.thoughtworks.xstream.annotations.XStreamAlias;

import hudson.DescriptorExtensionList;
import hudson.Extension;
import hudson.FilePath;
@@ -70,15 +73,10 @@
private int thresholdMode;
private ExtraConfiguration extraConfiguration;

public XUnitPublisher(@CheckForNull TestType[] tools, @CheckForNull XUnitThreshold[] thresholds) {
this.types = (tools != null ? Arrays.copyOf(tools, tools.length) : new TestType[0]);
this.thresholds = (thresholds != null ? Arrays.copyOf(thresholds, thresholds.length) : new XUnitThreshold[0]);
this.thresholdMode = 1;
}

@DataBoundConstructor
public XUnitPublisher(@CheckForNull TestType[] tools, @CheckForNull XUnitThreshold[] thresholds, int thresholdMode, @CheckForNull String testTimeMargin) {
this(tools, thresholds);
this.types = (tools != null ? Arrays.copyOf(tools, tools.length) : new TestType[0]);
this.thresholds = (thresholds != null ? Arrays.copyOf(thresholds, thresholds.length) : new XUnitThreshold[0]);
this.thresholdMode = thresholdMode;
long longTestTimeMargin = XUnitDefaultValues.TEST_REPORT_TIME_MARGING;
if (testTimeMargin != null && testTimeMargin.trim().length() != 0) {
@@ -151,12 +149,12 @@ public boolean performDryRun(AbstractBuild<?, ?> build, Launcher launcher, Build
return true;
}


@Override
public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.NONE;
}

@Symbol("xunit")
@Extension
public static final class XUnitDescriptorPublisher extends BuildStepDescriptor<Publisher> {

@@ -24,11 +24,14 @@

package org.jenkinsci.plugins.xunit.threshold;

import org.jenkinsci.Symbol;

import hudson.Extension;

/**
* @author Gregory Boissinot
*/
@Symbol("failed")
@Extension
public class FailedThresholdDescriptor extends XUnitThresholdDescriptor<FailedThreshold> {

@@ -24,11 +24,14 @@

package org.jenkinsci.plugins.xunit.threshold;

import org.jenkinsci.Symbol;

import hudson.Extension;

/**
* @author Gregory Boissinot
*/
@Symbol("skipped")
@Extension
public class SkippedThresholdDescriptor extends XUnitThresholdDescriptor<SkippedThreshold> {

@@ -24,18 +24,28 @@

package org.jenkinsci.plugins.xunit.types;

import hudson.Extension;
import org.jenkinsci.Symbol;
import org.jenkinsci.lib.dtkit.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;

/**
* <a href=
* "http://docs.adacore.com/live/wave/aunit/html/aunit_cb/aunit_cb.html">AUnit</a>
* is a unit testing framework of the xUnit family for the Ada language,
* originally developed by Ed Falis and maintained by AdaCore, distributed
* together with GNAT.
*/
public class AUnitJunitHudsonTestType extends TestType {

@DataBoundConstructor
public AUnitJunitHudsonTestType(String pattern, boolean skipNoTestFiles, boolean failIfNotNew, boolean deleteOutputFiles, boolean stopProcessingIfError) {
super(pattern, skipNoTestFiles, failIfNotNew, deleteOutputFiles, stopProcessingIfError);
}

@Symbol("AUnit")
@Extension
public static class DescriptorImpl extends TestTypeDescriptor<AUnitJunitHudsonTestType> {

@@ -24,18 +24,26 @@

package org.jenkinsci.plugins.xunit.types;

import hudson.Extension;
import org.jenkinsci.Symbol;
import org.jenkinsci.lib.dtkit.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;

/**
* <a href="http://www.boost.org/doc/libs/release/libs/test">Boost.Test</a> is a
* C++03 and C++11/14 unit testing library, available on a wide range of
* platforms and compilers. The library is part of Boost.
*/
public class BoostTestJunitHudsonTestType extends TestType {

@DataBoundConstructor
public BoostTestJunitHudsonTestType(String pattern, boolean skipNoTestFiles, boolean failIfNotNew, boolean deleteOutputFiles, boolean stopProcessingIfError) {
super(pattern, skipNoTestFiles, failIfNotNew, deleteOutputFiles, stopProcessingIfError);
}

@Symbol("BoostTest")
@Extension
public static class DescriptorImpl extends TestTypeDescriptor<BoostTestJunitHudsonTestType> {

@@ -24,12 +24,20 @@

package org.jenkinsci.plugins.xunit.types;

import hudson.Extension;
import org.jenkinsci.Symbol;
import org.jenkinsci.lib.dtkit.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;

/**
* <a href="https://cmake.org/Wiki/CMake/Testing_With_CTest">CTest</a> is a
* testing tool distributed as a part of CMake. It can be used to automate
* updating (using CVS for example), configuring, building, testing, performing
* memory checking, performing coverage, and submitting results to a CDash or
* Dart dashboard system.
*
* @author Gregory Boissinot
*/
public class CTestType extends TestType {
@@ -39,6 +47,7 @@ public CTestType(String pattern, boolean skipNoTestFiles, boolean failIfNotNew,
super(pattern, skipNoTestFiles, failIfNotNew, deleteOutputFiles, stopProcessingIfError);
}

@Symbol("CTest")
@Extension
public static class CTestTypeDescriptor extends TestTypeDescriptor<CTestType> {

@@ -24,18 +24,28 @@

package org.jenkinsci.plugins.xunit.types;

import hudson.Extension;
import org.jenkinsci.Symbol;
import org.jenkinsci.lib.dtkit.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;

/**
* <a href="http://cunit.sourceforge.net">CUnit</a> is a lightweight system for
* writing, administering, and running unit tests in C.
* <p>
* It provides C programmers a basic testing functionality with a flexible
* variety of user interfaces.
*/
public class CUnitJunitHudsonTestType extends TestType {

@DataBoundConstructor
public CUnitJunitHudsonTestType(String pattern, boolean skipNoTestFiles, boolean failIfNotNew, boolean deleteOutputFiles, boolean stopProcessingIfError) {
super(pattern, skipNoTestFiles, failIfNotNew, deleteOutputFiles, stopProcessingIfError);
}

@Symbol("CUnit")
@Extension
public static class DescriptorImpl extends TestTypeDescriptor<CUnitJunitHudsonTestType> {

0 comments on commit e52107f

Please sign in to comment.
You can’t perform that action at this time.