Skip to content

Execute tests from absolute path of a scenario file #722

Open

Description

@authorjapps

Currently the Zerocode runner can execute a test from the Classpath. That's fine and we will retain this as this is given default to us.
See example:
https://github.com/authorjapps/zerocode/blob/master/http-testing-examples/src/test/java/org/jsmart/zerocode/testhelp/tests/helloworld/JustHelloWorldTest.java

@TargetEnv("github_host.properties")
@RunWith(ZeroCodeUnitRunner.class)
public class JustHelloWorldTest {

    @Test
    @Scenario("helloworld/hello_world_status_ok_assertions.json") <---------- picks from Classapth
    public void testGet() throws Exception {
    }

}

AC1:

But, we need a mechanism to make it flexible to run even if

  • absolute path is provided to the scenario file

Example :

    @Test
    //  should pick from absolute path and run //
    @Scenario("/home/authorj/code/zerocode/http-testing-examples/src/test/resources/helloworld/hello_world_status_ok_assertions.json")
    public void testGet() throws Exception {
    }

This will give us flexibility help to run from a CI tool by any path.

AC = Acceptance Criteria

Activity

  1. poseidontor commented on Aug 20, 2025

    @poseidontor
    Collaborator

    Hi @authorjapps , I can see that even in the current implementation reading scenario file from absolute path is supported.

    if (isValidAbsolutePath(scenarioFile)) {

    I tested the same too. Is anything else expected here?

  2. authorjapps commented on Aug 20, 2025

    @authorjapps
    OwnerAuthor

    Hi @authorjapps , I can see that even in the current implementation reading scenario file from absolute path is supported.

    zerocode/core/src/main/java/org/jsmart/zerocode/core/utils/SmartUtils.java

    Line 67 in 9659ccd

    if (isValidAbsolutePath(scenarioFile)) {
    I tested the same too. Is anything else expected here?

    That's interesting, good spot @poseidontor ! 👍

    Then we need a test-scenario I think in our test pack here in the "http-testing-examples" module here
    or
    anywhere(e.g. here) TBH to run it via the CI pipeline.

    Just check(when you get chance), if it's possible to add or already there (before by chance) ?

  3. poseidontor commented on Aug 20, 2025

    @poseidontor
    Collaborator

    Hi @authorjapps , I can see that even in the current implementation reading scenario file from absolute path is supported.
    zerocode/core/src/main/java/org/jsmart/zerocode/core/utils/SmartUtils.java
    Line 67 in 9659ccd
    if (isValidAbsolutePath(scenarioFile)) {
    I tested the same too. Is anything else expected here?

    That's interesting, good spot @poseidontor ! 👍

    Then we need a test-scenario I think in our test pack here in the "http-testing-examples" module here or anywhere(e.g. here) TBH to run it via the CI pipeline.

    Just check(when you get chance), if it's possible to add or already there (before by chance) ?

    @authorjapps there are test cases for this here

  4. authorjapps commented on Aug 20, 2025

    @authorjapps
    OwnerAuthor

    @authorjapps there are test cases for this here

    Yep, thanks for finding that @poseidontor ! Good spot once again. That's a unit test.

    Is there any integration test?
    I understand it may not be straightforward to write one, but please check if one already exists.

    Otherwise, we'll need to add one to confirm it works in an integration scenario.

    I am also thinking how we can achieve it. Probably the same way the unit test works out the abs path?

    Once we figure out this, we can add a IT test and close this ticket.

  5. poseidontor commented on Aug 25, 2025

    @poseidontor
    Collaborator

    Sure! @authorjapps I will try to figure out how we can have a IT test for this scenario

  6. poseidontor commented on Aug 26, 2025

    @poseidontor
    Collaborator

    Hi @authorjapps, whenever you can time can you please check #726 and let me know if it passess the acceptance criteria. Also I am open to suggestion for any code improvement.

  7. self-assigned this
    on Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions