-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2479 from dvargas46/develop
fix system properties issue on runner #2474
- Loading branch information
Showing
2 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
karate-core/src/test/java/com/intuit/karate/SystemPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.intuit.karate; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import com.intuit.karate.Runner.Builder; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class SystemPropertiesTest { | ||
|
||
private static final String TEST_PROP = "testProperty"; | ||
|
||
@AfterEach | ||
void clearTestProperty() { | ||
System.clearProperty(TEST_PROP); | ||
} | ||
|
||
@Test | ||
void testSystemPropertiesSetOnRunner() { | ||
Builder<?> builder = Runner.builder().systemProperty(TEST_PROP, "setOnRunner"); | ||
builder.resolveAll(); | ||
String propertyValue = builder.systemProperties.get(TEST_PROP); | ||
assertEquals(propertyValue, "setOnRunner"); | ||
} | ||
|
||
@Test | ||
void testSystemPropertiesSetOnJVM() { | ||
System.setProperty(TEST_PROP, "setOnJVM"); // -DtestProperty=setOnJVM | ||
Builder<?> builder = Runner.builder(); | ||
builder.resolveAll(); | ||
String propertyValue = builder.systemProperties.get(TEST_PROP); | ||
assertEquals(propertyValue, "setOnJVM"); | ||
} | ||
|
||
@Test | ||
void testPrecedenceOfSystemPropertiesSetOnRunnerAndJVM() { | ||
System.setProperty(TEST_PROP, "setOnJVM"); // -DtestProperty=setOnJVM | ||
Builder<?> builder = Runner.builder().systemProperty(TEST_PROP, "setOnRunner"); | ||
builder.resolveAll(); | ||
String propertyValue = builder.systemProperties.get(TEST_PROP); | ||
assertEquals(propertyValue, "setOnJVM"); | ||
} | ||
} |