zerocode icon indicating copy to clipboard operation
zerocode copied to clipboard

Execute tests from absolute path of a scenario file

Open authorjapps opened this issue 5 months ago • 6 comments

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

authorjapps avatar Aug 11 '25 17:08 authorjapps

Hi @authorjapps , I can see that even in the current implementation reading scenario file from absolute path is supported. https://github.com/authorjapps/zerocode/blob/9659ccd03748a3650c2a5c75c5da460139b2d6a7/core/src/main/java/org/jsmart/zerocode/core/utils/SmartUtils.java#L67

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

poseidontor avatar Aug 20 '25 12:08 poseidontor

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 avatar Aug 20 '25 12:08 authorjapps

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

poseidontor avatar Aug 20 '25 13:08 poseidontor

@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.

authorjapps avatar Aug 20 '25 19:08 authorjapps

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

poseidontor avatar Aug 25 '25 16:08 poseidontor

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

poseidontor avatar Aug 26 '25 04:08 poseidontor