I hope it isn't a duplicate as I looked around and could not find an answer.
I have a batch script witch uses python coverage tool to execute tests and measure coverage.
the scripts traverse through all sub folders of a main unit tests folder and execute tests.
The thing is, I need to call coverage run
command from the same folder where my tests files are so I need to first change the batch current directory to the directory of the current test, for each test.
How can it be done?
This is my current script
@echo off
for /r %%f in (Test_*.py) do (
echo current test (full path) is %%f
:: I need a way to change CD to the directory of %%f
:: before running the test. the problem is that %%f contains the file
:: name so I cant just `cd %f%`
coverage run -a "%%f"
)
coverage report > "coverage_results.txt"
coverage erase
pause
Thanks