How to create single loggin report from multiple testing files? - python

I have several test files and I run them one by one using a .bat file.
The batch file looks like this:
py.test --html=Myreport.html -v testfile1.py --tb=short
py.test --html=Myreport.html -v testfile2.py --tb=short
py.test --html=Myreport.html -v testfile3.py --tb=short
The problem is that each test run will overwrite Myreport.html report (so in this case the report will contain only tests present in testfile3.py file as those from the other two files were overwritten).
Is there any way to have all the test results in a single HTML file report?
Thanks

Related

can I specify which test files to run in .coveragerc?

My file structure is below,
Logic
--packageA
----file1
----file2
--packageB
----file3
----file4
--tests
----testfile1
----testfile2
----testfile3
--.coveragerc
I'd like to include packageA only for tests, and run testfile1 and testfile2 to measure the coverage.
testfile3 is for packageB.
So I wrote my .coveragerc file,
[run]
branch = True
include = /packageA/*
omit = *tests*
and, when I run coverage with command coverage run --rcfile=../.coveragerc -m pytest in directory tests, it tries running testfile3 as well.
How can I run testfile1 and testfile2 with .coveragerc configuration?
You can use the [run] command_line option to set the command line to use when you run coverage run. But coverage isn't trying to be a general runner. You might want a shell script, a Makefile, or a tox.ini file instead.
Are you typing the coverage run --rcfile=../.coveragerc -m pytest command by hand?

How to set target folder for Allure Html report in Behave

I was able to generate allure json files using command :
behave -f allure_behave.formatter:AllureFormatter -o C:\\Users\\QA\\PycharmProjects\\webAutomationFramework\\allure-results
Once I run above command, it run all the feature files of behave and generate required .json files into folder allure-results
Now when I run the command : allure serve C:\\Users\\QA\\PycharmProjects\\webAutomationFramework\\allure-results , it generates allure report proper on some temp URL i.e http://192.168.0.102:54603/index.html#suites
Here I want to store this allure HTML report into some specific folder but I don't know how.
I ran below command but that seems to generate the blank report :
X:\seleniumlibrary\allure-2.6.0\bin\allure.bat generate "C:\\Users\\QA\\PycharmProjects\\webAutomationFramework\\allure-results-o "C:\\Users\\QA\\PycharmProjects\\webAutomationFramework\\allure-results\\Reports\\LoginReports"
Use --alluredir flag
behave -f allure_behave.formatter:AllureFormatter -o C:\\Users\\QA\\PycharmProjects\\webAutomationFramework\\allure-results --alluredir C:\\Users\\QA\\PycharmProjects\\webAutomationFramework\\allure-results\\Reports\\LoginReports

force pytest.main() to use a different pytest.ini

Is there a way to point pytest at a differnt pytest.ini file?
The application I am working on has one pytest.ini file that is used for running unittests when it spins up, and I do not want to modify that file.
I do however want to point pytest at a different file when running my automation tests via pytest.main()
pytest.main(['-p', 'no:django', '-v', '--json-report', '-m', test_marker])
Is there a way to tell pytest to use a pytest.ini file from another location?
$ pytest --help | grep -F config
-c file load configuration from `file` instead of trying to
locate one of the implicit configuration files.
That is,
pytest.main(['-c', 'pytest-alt.ini'])

nose get list of test without running them

Is there a way to get a list of all the tests currently recognized by nose, without running them?
According to the doc
--collect-only Enable collect-only: Collect and output test names only, don't run any tests. [COLLECT_ONLY]
However when I do nosetests --collect-only I get:
Ran 101 tests in 0.642s
OK
How can I get names those tests?
Try with the -v option:
nosetests -v --collect-only
If you're trying to debug how nose actually finds your tests, go for -vv

How to output coverage XML with nosetests?

I'm trying to output the coverage XML of my nosetests so they show up on Hudson. The line I'm executing is:
nosetests --with-gae -v --all-modules --with-xunit --with-coverage
I see the coverage output in the console, but there's no xml file containing the coverage data. How can I get it to output the coverage xml?
Once you've run the nosetests command, there will be a .coverage data file in the directory. If you then run coverage xml, it will create a Cobertura-compatible XML file from the .coverage file.
There is a plugin written for nosetests to do just this.
You just have to add --with-xcoverage once this package is installed. It can be found at:
https://github.com/cmheisel/nose-xcover

Categories

Resources