I need to generate a test report using HTMLTestRunner ,for that code (which is placed at the end of the file) is:
suite = unittest.TestLoader().loadTestsFromTestCase(TestLoginPages)
outfile = open("/home/xxx/xxx/xxxx/report.html", "w")
runner = HTMLTestRunner.HTMLTestRunner(
stream=outfile,
title='Test Report',
description='Test report for the application')
runner.run(suite)
Then I run the test cases from pycharm ,all the tests are running twice. I have tried to 'Edit Configurations' in the 'Run' menu where I delete the 'unittest in my_file_name' configuration, but issue remains same
Make sure your manage.py file contains
if __name__ == "__main__":
...
execute_from_command_line(sys.argv)
PyCharm tries to make import of manage.py file to be sure there are no import errors. If your manage.py file does not contain name == "main" validation, then tests run on import stage as if they were launched from the bash and then PyCharm runs them directly once more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With