question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support system properties through classpath based file

See original GitHub issue

Kotest 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:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sksamuelcommented, Jan 24, 2021

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.

1reaction
sksamuelcommented, Jan 3, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found