You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Execute tests from a relative path of a scenario file from the PWD(Present Working Directory) #723
@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
relative path is provided to the scenario file
Example 1:
$pwd
/home/authorj/code/zerocode
$
then, I should be able to run using below:
@Test
// should pick from relative-apth from PWD //
@Scenario("./http-testing-examples/src/test/resources/helloworld/hello_world_status_ok_assertions.json")
public void testGet() throws Exception {
}
// in the above PWD = /home/authorj/code/zerocode, which is represented by "."
Example 2:
$pwd
/home/authorj/code/zerocode/http-testing-examples/src
$
then, I should be able to run using below:
@Test
// should pick from relative-apth from PWD //
@Scenario("./test/resources/helloworld/hello_world_status_ok_assertions.json")
public void testGet() throws Exception {
}
// in the above PWD = /home/authorj/code/zerocode/http-testing-examples/src, which is represented by "."
When you're ready or just before you implement the solution, can you put a summary of what approach or solution you would be implementing?
This will make everyone to be in sync for PR reviews.
So I can modify the readJsonAsString function with the following additions in the try statement.
String pwd = System.getProperty("user.dir");
if (scenarioFile.startsWith("./") || scenarioFile.startsWith("../")) {
// Relative path: Resolve from PWD
scenarioFile = Paths.get(pwd, scenarioFile.substring(2)).normalize().toString(); // Adjust for ../
}
Could you let me know if this makes sense? And are you aware of any other files / function where a change needs to be made to resolve this issue?
Hello @pratyushkumar211 , Thanks for asking. Looks good to me.
But, can you also have a look this has not already implemented like the other ticket for full abs path?
If not, then your solution approach should work I think.
Another query, will this "user.dir" work for Windows OS? worth checking
Is there no other way to work out the PWD for all OS in general ?
Thanks @nirmalchandra. I double checked and did not found this relative path feature implemented already like the abs path, and the String pwd = System.getProperty("user.dir"); command should work for all OS in general as well.
I have submitted the following PR #727 to resolve this. I will look forward to hearing feedback on my proposed changes and getting the updates incorporated in the main repo. Thanks.
Thanks @nirmalchandra. I double checked and did not found this relative path feature implemented already like the abs path, and the String pwd = System.getProperty("user.dir"); command should work for all OS in general as well.
I have submitted the following PR #727 to resolve this. I will look forward to hearing feedback on my proposed changes and getting the updates incorporated in the main repo. Thanks.
Thanks @pratyushkumar211 ,
Can you check the PR comments and fix them?
Thanks @nirmalchandra. However, I don't see any comments in my PR (#727) and it only says "Review Required" or "1 workflow awaiting approval" like in the screenshot below. Could you let me know how could I check whether those builds are successful or not?
Activity
pratyushkumar211 commentedon Aug 23, 2025
Hello, I am a first time contributor and interested in making a change to resolve this issue. Can I take this up? Thanks
authorjapps commentedon Aug 24, 2025
@pratyushkumar211 , Yes please go ahead. Thanks for your interest.
When you're ready or just before you implement the solution, can you put a summary of what approach or solution you would be implementing?
This will make everyone to be in sync for PR reviews.
pratyushkumar211 commentedon Aug 24, 2025
Thanks @authorjapps !
I was thinking that the Scenario path gets resolved in the function
public static String readJsonAsString(String scenarioFile)in this file: https://github.com/authorjapps/zerocode/blob/master/core/src/main/java/org/jsmart/zerocode/core/utils/SmartUtils.javaSo I can modify the readJsonAsString function with the following additions in the try statement.
Could you let me know if this makes sense?
And are you aware of any other files / function where a change needs to be made to resolve this issue?
nirmalchandra commentedon Aug 30, 2025
Hello @pratyushkumar211 , Thanks for asking. Looks good to me.
But, can you also have a look this has not already implemented like the other ticket for full abs path?
If not, then your solution approach should work I think.
Anyway give it a go, and go ahead with the PR.
pratyushkumar211 commentedon Sep 6, 2025
Thanks @nirmalchandra. I double checked and did not found this relative path feature implemented already like the abs path, and the String pwd = System.getProperty("user.dir"); command should work for all OS in general as well.
I have submitted the following PR #727 to resolve this. I will look forward to hearing feedback on my proposed changes and getting the updates incorporated in the main repo. Thanks.
nirmalchandra commentedon Sep 6, 2025
Thanks @pratyushkumar211 ,
Can you check the PR comments and fix them?
pratyushkumar211 commentedon Sep 6, 2025
Thanks @nirmalchandra. However, I don't see any comments in my PR (#727) and it only says "Review Required" or "1 workflow awaiting approval" like in the screenshot below. Could you let me know how could I check whether those builds are successful or not?
Thank you
nirmalchandra commentedon Sep 6, 2025
Here is the screenshot of the comment. Let me check why GitHub is not showing you
Yaksha50 commentedon Oct 21, 2026
Hello, I am begginer in open source contribution and I would like to contribute in this issue. Can I take up this?