JUnit tag support
- Prepare build so that we can use JUnit tags and define shellIncludeTags/shellExcludeTags from command line to override settings. - Needed for some of a new planned tests which would not work without full build. - Relates #1131
This commit is contained in:
@@ -39,6 +39,9 @@ import org.gradle.external.javadoc.CoreJavadocOptions;
|
||||
class JavaConventions {
|
||||
|
||||
private static final String SOURCE_AND_TARGET_COMPATIBILITY = "17";
|
||||
private static final String INCLUDE_TAGS = "shellIncludeTags";
|
||||
private static final String EXCLUDE_TAGS = "shellExcludeTags";
|
||||
private static final String[] DEFAULT_EXCLUDE_TAGS = new String[] { };
|
||||
|
||||
void apply(Project project) {
|
||||
project.getPlugins().withType(JavaBasePlugin.class, java -> {
|
||||
@@ -83,7 +86,31 @@ class JavaConventions {
|
||||
|
||||
private void configureTestConventions(Project project) {
|
||||
project.getTasks().withType(Test.class, test -> {
|
||||
test.useJUnitPlatform();
|
||||
boolean hasIncludeTags = project.hasProperty(INCLUDE_TAGS);
|
||||
boolean hasExcludeTags = project.hasProperty(EXCLUDE_TAGS);
|
||||
test.useJUnitPlatform(options -> {
|
||||
if (!hasIncludeTags && !hasExcludeTags) {
|
||||
options.excludeTags(DEFAULT_EXCLUDE_TAGS);
|
||||
}
|
||||
else {
|
||||
if (hasIncludeTags) {
|
||||
Object includeTagsProperty = project.property(INCLUDE_TAGS);
|
||||
if (includeTagsProperty instanceof String p) {
|
||||
if (p.length() > 0) {
|
||||
options.includeTags(p.split(","));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasExcludeTags) {
|
||||
Object excludeTagsProperty = project.property(EXCLUDE_TAGS);
|
||||
if (excludeTagsProperty instanceof String p) {
|
||||
if (p.length() > 0) {
|
||||
options.excludeTags(p.split(","));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user