Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The parameter givenConfigFileName cannot be passed through the public functions createStub(...) #1375

Open
crcaguilerapo opened this issue Oct 23, 2024 · 3 comments
Assignees
Labels
answered The issue has been answered

Comments

@crcaguilerapo
Copy link

crcaguilerapo commented Oct 23, 2024

givenConfigFileName: String? = null,

I think it's important to be able to pass the Specmatic configuration path for cases when it is stored in a different location than the root of the Java project.

At the moment, that attribute is inaccessible to developers.

@pranavgawri pranavgawri self-assigned this Nov 12, 2024
@pranavgawri
Copy link
Contributor

Hi @crcaguilerapo ,

Apologies for the late response. Thanks for sharing your concern. I will check this and get back to you ASAP.

Thanks,
Pranav

@pranavgawri pranavgawri added question Further information is requested needs_verification Issue is to be verified and confirmed and removed question Further information is requested labels Nov 12, 2024
@pranavgawri
Copy link
Contributor

Hi @crcaguilerapo ,

Thanks for your patience. There is an existing supported way to specify the configuration file path when working programmatically.

While the givenConfigFileName parameter is internal, you can specify the configuration file path using the CONFIG_FILE_PATH environment variable. This gives you the flexibility to store your Specmatic configuration file anywhere in your project structure.

Please refer the documentation for more details

Please let me know if this help.

Thanks,
Pranav

@pranavgawri pranavgawri added answered The issue has been answered awaiting-response Awaiting response from client and removed needs_verification Issue is to be verified and confirmed awaiting-response Awaiting response from client labels Nov 13, 2024
@crcaguilerapo
Copy link
Author

Hello @pranavgawri,

Thank you! You are right, this worked very well for me in the contract tests,

// .../adapter/in/ExampleContractTest.java
@MicronautTest
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class ExampleContractTest implements SpecmaticContractTest {

    @Inject
    EmbeddedServer server;

    @BeforeAll
    public void setUp() {
        if (!server.isRunning()) {
            server.start();
        }
       
        System.setProperty("CONFIG_FILE_PATH", "/path/to/specmatic.yaml");
        System.setProperty("host", server.getHost());
        System.setProperty("port", String.valueOf(server.getPort()));
    }

    @Test
    public void initExecution() {}
}

but when setting up the virtual server of Specmatic to perform integration tests, it didn't work.

@MicronautTest
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class ExampleIntegrationTest {

    private ContractStub stub;
    
    @BeforeAll
    public void setUp() {
        ...
        System.setProperty("CONFIG_FILE_PATH", "/path/to/specmatic.yaml")
        stub = createStub(HOST, PORT, true);
    }

    @AfterAll
    public void tearDown() throws IOException {
        stub.close();
    }
}

Do you know what could be wrong?

Thank you,
Cristian Aguilera

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered The issue has been answered
Projects
None yet
Development

No branches or pull requests

2 participants