-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for configuration parameters resources #3345
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -895,13 +895,16 @@ engines running on the JUnit Platform via one of the following mechanisms. | |||||||||||||
`systemProperty` or `systemProperties` DSL. | ||||||||||||||
* <<running-tests-build-maven-config-params,Maven Surefire provider>>: use the | ||||||||||||||
`configurationParameters` property. | ||||||||||||||
2. JVM system properties. | ||||||||||||||
3. The JUnit Platform configuration file: a file named `junit-platform.properties` in the | ||||||||||||||
2. The `configurationParametersResource()` and `configurationParametersResources()` | ||||||||||||||
methods in the `LauncherDiscoveryRequestBuilder` which are used to select a `.properties` | ||||||||||||||
file on the classpath with configuration parameters. | ||||||||||||||
Comment on lines
+898
to
+900
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The |
||||||||||||||
3. JVM system properties. | ||||||||||||||
4. The JUnit Platform configuration file: a file named `junit-platform.properties` in the | ||||||||||||||
root of the class path that follows the syntax rules for a Java `Properties` file. | ||||||||||||||
|
||||||||||||||
NOTE: Configuration parameters are looked up in the exact order defined above. | ||||||||||||||
Consequently, configuration parameters supplied directly to the `Launcher` take | ||||||||||||||
precedence over those supplied via system properties and the configuration file. | ||||||||||||||
precedence over those supplied via system properties, the specified properties files, and the platform configuration file. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Also, please wrap lines in Asciidoc files at 90 characters. |
||||||||||||||
Similarly, configuration parameters supplied via system properties take precedence over | ||||||||||||||
those supplied via the configuration file. | ||||||||||||||
|
||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -66,6 +66,7 @@ public class TestDiscoveryOptions { | |||||
private List<String> includedTagExpressions = emptyList(); | ||||||
private List<String> excludedTagExpressions = emptyList(); | ||||||
|
||||||
private List<String> configurationParametersResources = emptyList(); | ||||||
private Map<String, String> configurationParameters = emptyMap(); | ||||||
|
||||||
public boolean isScanModulepath() { | ||||||
|
@@ -262,4 +263,12 @@ public void setConfigurationParameters(Map<String, String> configurationParamete | |||||
this.configurationParameters = configurationParameters; | ||||||
} | ||||||
|
||||||
public List<String> getConfigurationParametersResources() { | ||||||
return configurationParametersResources; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
public TestDiscoveryOptions setConfigurationParametersResources(List<String> configurationParametersResources) { | ||||||
this.configurationParametersResources = configurationParametersResources; | ||||||
return this; | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,6 +30,7 @@ | |||||
import org.junit.platform.launcher.TestPlan; | ||||||
import org.junit.platform.launcher.core.LauncherFactory; | ||||||
import org.junit.platform.suite.api.ConfigurationParameter; | ||||||
import org.junit.platform.suite.api.ConfigurationParametersResource; | ||||||
import org.junit.platform.suite.api.ExcludeClassNamePatterns; | ||||||
import org.junit.platform.suite.api.ExcludeEngines; | ||||||
import org.junit.platform.suite.api.ExcludePackages; | ||||||
|
@@ -105,6 +106,7 @@ | |||||
* @see SuiteDisplayName | ||||||
* @see org.junit.platform.suite.api.UseTechnicalNames UseTechnicalNames | ||||||
* @see ConfigurationParameter | ||||||
* @see ConfigurationParametersResource ConfigurationParametersResource | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* @deprecated since 1.8, in favor of the {@link Suite @Suite} support provided by | ||||||
* the {@code junit-platform-suite-engine} module; to be removed in JUnit Platform 2.0 | ||||||
*/ | ||||||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,51 @@ | ||||
/* | ||||
* Copyright 2015-2023 the original author or authors. | ||||
* | ||||
* All rights reserved. This program and the accompanying materials are | ||||
* made available under the terms of the Eclipse Public License v2.0 which | ||||
* accompanies this distribution and is available at | ||||
* | ||||
* https://www.eclipse.org/legal/epl-v20.html | ||||
*/ | ||||
|
||||
package org.junit.platform.suite.api; | ||||
|
||||
import static org.apiguardian.api.API.Status.EXPERIMENTAL; | ||||
|
||||
import java.lang.annotation.Documented; | ||||
import java.lang.annotation.ElementType; | ||||
import java.lang.annotation.Inherited; | ||||
import java.lang.annotation.Repeatable; | ||||
import java.lang.annotation.Retention; | ||||
import java.lang.annotation.RetentionPolicy; | ||||
import java.lang.annotation.Target; | ||||
|
||||
import org.apiguardian.api.API; | ||||
|
||||
/** | ||||
* {@code @ConfigurationParametersResource} is an annotation that specifies | ||||
* a configuration file in property format to be added to the discovery request when running | ||||
* a test suite on the JUnit Platform. | ||||
* | ||||
* @since 1.11 | ||||
* @see DisableParentConfigurationParameters | ||||
* @see Suite | ||||
* @see org.junit.platform.runner.JUnitPlatform | ||||
* @see org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder#configurationParameter(String, String) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This method no longer exists -- right? |
||||
*/ | ||||
@Retention(RetentionPolicy.RUNTIME) | ||||
@Target(ElementType.TYPE) | ||||
@Inherited | ||||
@Documented | ||||
// TODO: Before PR merge, change to STABLE/MAINTAINED | ||||
// TODO: Is version 1.11 correct? | ||||
robinjhector marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
@API(status = EXPERIMENTAL, since = "1.11") | ||||
@Repeatable(ConfigurationParametersResources.class) | ||||
public @interface ConfigurationParametersResource { | ||||
|
||||
/** | ||||
* The classpath location for the desired properties file; never {@code null} or blank. | ||||
*/ | ||||
String resource(); | ||||
robinjhector marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2015-2023 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.platform.suite.api; | ||
|
||
import static org.apiguardian.api.API.Status.EXPERIMENTAL; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.apiguardian.api.API; | ||
|
||
/** | ||
* {@code @ConfigurationParametersResources} is a container for one or more | ||
* {@link ConfigurationParametersResource @ConfigurationParametersResource} declarations. | ||
* | ||
* <p>Note, however, that use of the {@code @ConfigurationParametersResources} container | ||
* is completely optional since {@code @ConfigurationParametersResource} is a | ||
* {@linkplain java.lang.annotation.Repeatable repeatable} annotation. | ||
* | ||
* @since 1.8 | ||
* @see ConfigurationParametersResource | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
@Inherited | ||
@Documented | ||
// TODO: Before PR merge, change to STABLE/MAINTAINED | ||
// TODO: Is version 1.11 correct? | ||
@API(status = EXPERIMENTAL, since = "1.11") | ||
public @interface ConfigurationParametersResources { | ||
|
||
/** | ||
* An array of one or more {@link ConfigurationParametersResource @ConfigurationParameterResource} | ||
* declarations. | ||
*/ | ||
ConfigurationParametersResource[] value(); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Used in tests, don't delete me | ||
com.example.prop.first=first value from override file |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Used in tests, don't delete me | ||
com.example.prop.first=first value | ||
com.example.prop.second=second value | ||
com.example.prop.third=third value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
--config-resource
option should also be included in this bullet point listing, below the--config
discussion or incorporated into that discussion about the Console Launcher.