I used to have a excel sheet bound to my test case by
def dataUserPass = TestDataFactory.findTestData("myTable")
where "myTable" is relative id of a file located at C:/Users/myself/git/my-project/Data Files/myTable
.
Recently I moved my code to a server using Gitlab. Tests run fine on my computer, but when a co-worker tries to run this test they get this error message:
Test FAILED because (of) (Stack trace: java.lang.IllegalArgumentException: Cannot find test data with id 'Data Files/myTable' because (of) 'java.io.FileNotFoundException: C:\Users\myself\git\my-project\Data Files\myTable.xlsx'
So I tried to redefine my test data with:
def dataUserPass = TestDataFactory.findTestData(RunConfiguration.getProjectDir() + '/Data Files/myTable')
(RunConfiguration.getProjectDir()
returns C:\Users\myself\git\my-project\
)
But I got the following:
Test FAILED because (of) (Stack trace: java.lang.IllegalArgumentException: Cannot find test data with id 'Data Files/C:/Users/myself/git/my-project/Data Files/myTable' because (of) 'java.lang.IllegalArgumentException: Test data with id 'Data Files/C:/Users/myself/git/my-project/Data Files/myTable' does not exist'
I think you can add the excel file in the same folder with your "myTable" file in Data Files folder. Then in the data-file mapping, choose "Relative path". This setting will help your project locate the file using relative path and will can be executed from different machines.