Skip to content

Commit

Permalink
Make AggregateRequirements dependency on EnvironmentVariables explici…
Browse files Browse the repository at this point in the history
…t so that they can be mocked in the test
  • Loading branch information
jan-molak committed Dec 29, 2023
1 parent 252fbbe commit bc02c49
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public class AggregateRequirements implements Requirements {
private final RequirementsOutcomeFactory requirementsOutcomeFactory;

public AggregateRequirements(Path jsonOutcomes, String featureFilesDirectory) {
EnvironmentVariables environmentVariables = SystemEnvironmentVariables.currentEnvironmentVariables();
this(jsonOutcomes, featureFilesDirectory, SystemEnvironmentVariables.createEnvironmentVariables());
}

public AggregateRequirements(Path jsonOutcomes, String featureFilesDirectory, EnvironmentVariables environmentVariables) {
this.requirementsService = new AggregateRequirementsService(
environmentVariables,
new FileSystemRequirementsTagProvider(featureFilesDirectory, environmentVariables),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import net.serenitybdd.model.environment.ConfiguredEnvironment;
import net.thucydides.model.domain.RequirementCache;
import net.thucydides.model.environment.MockEnvironmentVariables;
import net.thucydides.model.environment.SystemEnvironmentVariables;
import net.thucydides.model.requirements.model.Requirement;
import net.thucydides.model.util.EnvironmentVariables;
import org.junit.jupiter.api.*;

import java.io.File;
Expand Down Expand Up @@ -107,7 +110,13 @@ private List<Requirement> requirementsFrom(Path exampleRootDirectory) {
Path requirementsDirectory = exampleRootDirectory.resolve("spec");
Path jsonOutcomesDirectory = exampleRootDirectory.resolve("outcomes");

Requirements requirements = new AggregateRequirements(jsonOutcomesDirectory, requirementsDirectory.toString());
EnvironmentVariables environmentVariables = new MockEnvironmentVariables();

Requirements requirements = new AggregateRequirements(
jsonOutcomesDirectory,
requirementsDirectory.toString(),
environmentVariables
);

return requirements.getRequirementsService().getRequirements();
}
Expand Down

0 comments on commit bc02c49

Please sign in to comment.