Support system properties through classpath based file
See original GitHub issueKotest 4.3.1
Kotest IDEA Plugin 1.1.22-IC-2020.1
Not sure if I should have posted this bug in the Kotest plugin repo or here.
I have a scenario where I want to inject sensitive information in a test for an end 2 end test.
Adding my sensitive information in Gradle by reading local.properties
file and setting it as a system property.
I can then retrieve it in my tests by quering the System.getProperty
.
This works if I run the test in the command line. ./gradlew test
but are not added when I run them from IntelliJ.
A simple example:
build.gradle
test {
useJUnitPlatform()
systemProperty "hello", "world"
}
test class
public class SystemPropTest : StringSpec({
"should retrieve the System property" {
System.getProperty("hello") shouldBe "world"
}
})
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
System Properties - Essential Java Classes
System Properties ; "java.class.path", Path used to find directories and JAR archives containing class files. Elements of the class path are separated by...
Read more >Properties with Spring and Spring Boot - Baeldung
Tutorial for how to work with properties files and property values in Spring.
Read more >59. Properties & configuration - Spring
A SpringApplication has bean properties (mainly setters) so you can use its Java API as you create the application to modify its behavior....
Read more >How to load system properties in Spring for properties file ...
It is actually possible in Spring to override certain properties by specifying a system property location to another file using this ...
Read more >Java Properties file examples - Mkyong.com
Load a properties file config.properties from project classpath, and retrieved the property value. src/main/resources/config.properties. db.url= ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In 4.4 we can add a kotest.properties file to the classpath, and each key=value pair will be added as a system property before the test engine starts.
So you can set system properties inside intellij in the run configuration detaults. See https://intellij-support.jetbrains.com/hc/en-us/community/posts/206245939-How-can-I-set-defaults-for-test-configurations-
In addition we could add support to read a file from the classpath. kotest.local.properties or something, from which we could set system properties before any tests run.