This PR includes an improvement for properly validating the user-defined file path for the networkRequestMocks.responseDataFile field in the test plan file. Previously, if a user specifies an invalid path to this field, it would fail the test with a generic assertion error. With this fix, the exact reason for the test failure is called out by a one-line error message in the console, and detailed information in the logs - thus indicating to the user that the test failed due to bad input data and not due to a legitimate issue in the app/code. The fix includes a change in the logic to validate the file path to now validate the directory path using proper Directory APIs.
Since the fix made for the above issue uncovers additional regressions, fixes for those have also been included -
Directory validations across the project now happen using a combination if IsValidPath, Directory.Exists and File.Exists calls, instead of just IsValidPath (which previously used logic not meant to validate directory paths, and also included File.Exists which should be separated)
IsValidPath, FileExists and Exists are now independent functions that will separately validate the Path string, the existence of File at the specified path and existence of Directory at the specified path. These functions have been applied to the appropriate places in the code.
Unit tests and mocks have been updated to use the functions above.
fileExists has been renamed to FileExists per proper naming convention
Checklist
[x] The code change is covered by unit tests. I have added tests that prove my fix is effective or that my feature works
[x] I have performed end-to-end test locally.
[x] New and existing unit tests pass locally with my changes
[x] I have commented my code, particularly in hard-to-understand areas
[x] I have made corresponding changes to the documentation
Detailed Description of Fixes in this PR
This PR includes an improvement for properly validating the user-defined file path for the networkRequestMocks.responseDataFile field in the test plan file. Previously, if a user specifies an invalid path to this field, it would fail the test with a generic assertion error. With this fix, the exact reason for the test failure is called out by a one-line error message in the console, and detailed information in the logs - thus indicating to the user that the test failed due to bad input data and not due to a legitimate issue in the app/code. The fix includes a change in the logic to validate the file path to now validate the directory path using proper Directory APIs.
Since the fix made for the above issue uncovers additional regressions, fixes for those have also been included -
IsValidPath
,Directory.Exists
andFile.Exists
calls, instead of justIsValidPath
(which previously used logic not meant to validate directory paths, and also includedFile.Exists
which should be separated)IsValidPath
,FileExists
andExists
are now independent functions that will separately validate thePath
string, the existence ofFile
at the specified path and existence ofDirectory
at the specified path. These functions have been applied to the appropriate places in the code.fileExists
has been renamed toFileExists
per proper naming conventionChecklist