pytest!! Path setting doesn't work : –json-report-file= path
Question:
I am saving the report via -json-report.
However, I want to save it to the desired path, but it is not saved.
refer to the page
https://pypi.org/project/pytest-json-report/
file tree
I want to save it as a file named ‘report.json’ in the ‘Reports’folder.
The test runs in the ‘TestCases’ folder.
|____Pages
| |____BasePage.py
| |____SignUpPage.py
|____TestCases
| |____BaseTest.py
| |____conftest.py
|____Reports
| |____report.json
I tried
All of the cases below failed. (The file was not saved…)
pytest test_mock.py --json-report-file ../Reports/report.json
pytest test_mock.py --json-report-file=../Reports/
pytest test_mock.py --json-report-file=../Reports
pytest test_mock.py --json-report-file=..Reportsreport.json
pytest test_mock.py --json-report-file "../Reports/report.json"
pytest test_mock.py --json-report-file="../Reports/report.json"
pytest test_mock.py --json-report-file=/Users/myname/code/python/Reports/report.json
What should I fix?
Answers:
It looks like you need to pass --json-report
in order to get the report and --json-report-path=PATH
is yet another option to specify the path (i.e. not use the default). Note the last example in the link.
So, you need something like
pytest test_mock.py --json-report --json-report-file=../Reports/report.json
Not sure if you need to specify file name or if omitted it will use the default one.
I am saving the report via -json-report.
However, I want to save it to the desired path, but it is not saved.
refer to the page
https://pypi.org/project/pytest-json-report/
file tree
I want to save it as a file named ‘report.json’ in the ‘Reports’folder.
The test runs in the ‘TestCases’ folder.
|____Pages
| |____BasePage.py
| |____SignUpPage.py
|____TestCases
| |____BaseTest.py
| |____conftest.py
|____Reports
| |____report.json
I tried
All of the cases below failed. (The file was not saved…)
pytest test_mock.py --json-report-file ../Reports/report.json
pytest test_mock.py --json-report-file=../Reports/
pytest test_mock.py --json-report-file=../Reports
pytest test_mock.py --json-report-file=..Reportsreport.json
pytest test_mock.py --json-report-file "../Reports/report.json"
pytest test_mock.py --json-report-file="../Reports/report.json"
pytest test_mock.py --json-report-file=/Users/myname/code/python/Reports/report.json
What should I fix?
It looks like you need to pass --json-report
in order to get the report and --json-report-path=PATH
is yet another option to specify the path (i.e. not use the default). Note the last example in the link.
So, you need something like
pytest test_mock.py --json-report --json-report-file=../Reports/report.json
Not sure if you need to specify file name or if omitted it will use the default one.