Comments (4)
group 'com.****.jenkins.library'
version '1.0-SNAPSHOT'
apply plugin: 'groovy'
apply plugin: 'idea'
sourceCompatibility = 11
targetCompatibility = 11
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
sourceSets {
main {
groovy {
srcDirs = ['src', 'vars']
}
resources {
srcDir('resources')
}
}
test {
groovy {
resources {
srcDir('test')
}
}
}
}
repositories {
maven {
url "***/maven-jenkins-release"
}
maven {
url "***/maven-public"
}
}
dependencies {
// Jenkins core
String JENKINS_VERSION = System.getenv('JENKINS_VERSION') ?: '2.303.3'
String JENKINS_PIPELINE_UNIT_VERSION = "1.9"
implementation group: 'org.jenkins-ci.main', name: 'jenkins-core', version: JENKINS_VERSION
testImplementation group: 'org.jenkins-ci.main', name: 'jenkins-core', version: JENKINS_VERSION
implementation group: 'com.lesfurets', name: 'jenkins-pipeline-unit', version: JENKINS_PIPELINE_UNIT_VERSION
testCompileOnly group: "org.junit.vintage", name: "junit-vintage-engine", version: "5.9.1"
// Test frameworks
//testImplementation group: "org.junit.vintage", name: "junit-vintage-engine", version: "5.9.1"
//testCompileOnly group: 'junit', name: 'junit', version: '4.13.1'
testImplementation group: 'junit', name: 'junit', version: '4.13.1'
testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
testImplementation group: 'com.lesfurets', name: 'jenkins-pipeline-unit', version: JENKINS_PIPELINE_UNIT_VERSION
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.5.13'
implementation group: 'org.codehaus.groovy', name: 'groovy-all', version: '3.0.6'
implementation group: 'com.lesfurets', name: 'jenkins-pipeline-unit', version: JENKINS_PIPELINE_UNIT_VERSION
// Jenkins plugins
implementation group: 'com.cloudbees', name: 'groovy-cps', version: '1.32'
implementation group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-step-api', version: '2.22', ext: 'jar'
implementation group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-api', version: '2.40', ext: 'jar'
implementation group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-cps', version: '2.83', ext: 'jar'
implementation group: 'org.6wind.jenkins', name: 'lockable-resources', version: '2.12', ext: 'jar'
implementation group: 'org.jenkins-ci.plugins', name: 'credentials', version: '2.6.1', ext: 'jar'
// TRICKY: The lib folder contains all other plugins *JAR* files if not found in Maven
//implementation fileTree(dir: 'lib', include: ['*.jar'])
}
test {
include "**/**Test.class"
useJUnit()
testLogging {
events "PASSED", "FAILED", "SKIPPED"
}
// delete old test reports
dependsOn cleanTest
// don't stop if tests fail
ignoreFailures = true
// minimize logging
testLogging.maxGranularity = 0
// show stdout from tests
onOutput { dest, event -> print event.message }
// show test results
def results = []
afterTest { desc, result ->
println "${desc.className.split("\\.")[-1]}: " +
"${desc.name}: ${result.resultType}"
}
afterSuite { desc, result ->
if (desc.className) { results << result }
}
doLast {
println "Tests: ${results.sum { it.testCount }}" +
", Failures: ${results.sum { it.failedTestCount }}" +
", Errors: ${results.sum { it.exceptions.size() }}" +
", Skipped: ${results.sum { it.skippedTestCount }}"
}
}
from jenkinspipelineunit.
src/test/CreateBuildInfoDescriptionTest.groovy
import com.lesfurets.jenkins.unit.BasePipelineTest
import org.junit.Before
import org.junit.Test
import static org.junit.Assert.assertEquals
class CreateBuildInfoDescriptionTest extends BasePipelineTest {
def createBuildInfoDescription
@Before
void setUp() {
super.setUp()
// load toAlphanumeric
createBuildInfoDescription = loadScript("vars/createBuildInfoDescription.groovy")
}
@Test
void testCall() {
// call toAlphanumeric and check result
def asset = ["api":[version:"1"],"gui":[version:"2"]]
def result = createBuildInfoDescription(asset)
assertEquals("<ul><li>api: 1</li><li>gui: 2</li></ul>", result)
}
}
from jenkinspipelineunit.
vars.createBuildInfoDescription.groovy
#!groovy
def call(artifacts) {
def description = "<ul>"
artifacts.each() {
description += "<li>${it.key}: ${it.value.version}</li>"
}
description += "</ul>"
return description.toString()
}
from jenkinspipelineunit.
I assume you mean "Gradle 7", since the latest Groovy version is 4.x. Anyways, I just merged a PR that updates to Gradle 8.x, please re-try and report back.
from jenkinspipelineunit.
Related Issues (20)
- mock for build step HOT 3
- NoClassDefFoundError java/lang/Module with 1.15 & 1.16 HOT 3
- JenkinsPipelineUnit - unable to mock getId() called within script block
- Can't access 'env' properties in nested bindings
- Mock method of shared with defaut parameter
- Stack overflow in tests; possible to disable interception for a class? HOT 1
- document addParam HOT 1
- How to mock object creation?
- Jenkins shared library unit tests - missing dependencies and assert singleton values HOT 1
- post-unsuccessful action is not executed for parallel stage when a substage fails
- Is it possible to run unit tests over a Jenkinsfile in a remote git repo? HOT 8
- Performance: Cross-test caching of loaded scripts HOT 3
- Mocking different return values for a method the second time it is called HOT 3
- Accessing constant from another file
- Defining environment variables is not clear HOT 1
- Custom method added with registerAllowedMethod is not being utilized. HOT 13
- Why are call stack items indented with 3 spaces? HOT 2
- Specify a way to add helper.registerAllowedMethod("readYaml") as per the stage HOT 4
- How to setup an initial gradle process HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jenkinspipelineunit.