我使用这个命令运行我的测试:
sh "${mvnHome}/bin/mvn clean test -e -Dgroups=categories.dbd"但有时我想做一个特定的测试。我该怎么做呢?
我读到我可以使用“这个项目是参数化的”,但是我不知道如何使用它。
我也看到了这个- https://plugins.jenkins.io/selected-tests-executor/,但是它还不够好,因为它需要一个外部文件。
发布于 2020-12-16 14:32:44
如果您使用maven-surefire-plugin,您可以简单地运行
sh "${mvnHome}/bin/mvn clean test -e -Dgroups=categories.dbd -Dtest=com.example.MyJavaTestClass"或
sh "${mvnHome}/bin/mvn clean test -e -Dgroups=categories.dbd -Dtest=com.example.MyJavaTestClass#myTestMethod"我建议在管道定义中为测试类/方法添加一个参数。
pipeline {
agent any
parameters {
string defaultValue: '', description: 'Test Name', name: 'TEST_NAME', trim: false
}
stages {
stage('run tests') {
steps {
script {
def optionalParameters = ""
if (params.TEST_NAME != null) {
optionalParameters += " -Dtest=" + params.TEST_NAME
}
sh "${mvnHome}/bin/mvn clean test -e -Dgroups=categories.dbd" + optionalParameters
}
}
}
...
}
...
}https://stackoverflow.com/questions/65323665
复制相似问题