-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
. t dont set env variables globally to test EnvironmentVariableReporter
- Loading branch information
1 parent
a80c919
commit c7fb16a
Showing
7 changed files
with
102 additions
and
111 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
32 changes: 21 additions & 11 deletions
32
...ests-tests/src/test/java/org/approvaltests/reporters/EnvironmentVariableReporterTest.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 |
---|---|---|
@@ -1,19 +1,29 @@ | ||
package org.approvaltests.reporters; | ||
|
||
import org.approvaltests.Approvals; | ||
import org.approvaltests.core.Options; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class EnvironmentVariableReporterTest { | ||
@Test | ||
public void testEnvironmentVariable() { | ||
var reporter = EnvironmentVariableReporter.INSTANCE.getReporter(); | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
Assertions.assertInstanceOf(MultiReporter.class, reporter); | ||
var multiReporter = (MultiReporter) reporter; | ||
var reporters = multiReporter.getReporters(); | ||
|
||
Assertions.assertEquals(2, reporters.length); | ||
Assertions.assertInstanceOf(DiffReporter.class, reporters[0]); | ||
Assertions.assertInstanceOf(QuietReporter.class, reporters[1]); | ||
public class EnvironmentVariableReporterTest | ||
{ | ||
@Test | ||
public void testEnvironmentVariable() | ||
{ | ||
var expected = """ | ||
DiffReporter, QuietReporter | ||
"""; | ||
try | ||
{ | ||
EnvironmentVariableReporter.ENVIRONMENT_VARIABLES = (s) -> "DiffReporter,QuietReporter"; | ||
var reporter = new EnvironmentVariableReporter().getReporter(); | ||
Approvals.verify(reporter, new Options().inline(expected)); | ||
} | ||
finally | ||
{ | ||
EnvironmentVariableReporter.ENVIRONMENT_VARIABLES = System::getenv; | ||
} | ||
} | ||
} |
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
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
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
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
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