Hello!
Already asked this question in one forum, but did not receive an answer. Duplicate here with all the results.
Essence of the question:
There is a jenkins that runs tests (python + wd). In the script body itself, there is a function for downloading HTMLTestRunner reports.
Jenkins does not show Finished: SUCCESS , despite the fact that the test itself fell. This happens because C: \ Program Files (x86) \ Jenkins \ jobs \ Џа®ўҐаЄ "ЁзЁп ¬®¤" mle ®Є® \ workspace> exit 0 .
I suspect that this behavior can be caused by the fact that the last f-th is just HTMLTestRunner, and it is constantly regardless of the results that f-th above writes the report successfully, so jenkins believes him and does not fall. Tell me how to get rid of it? I attach the code:

class ASeleniumLogin_1(unittest.TestCase): def test_001_LoginInSYSDev(self): assert "Login" in driver.title _ = wait.until(EC.element_to_be_clickable((By.ID, 'LoginForm_username'))) elem = driver.find_element_by_id("LoginForm_username1") # НИКОГДА НЕ НАЙДЕТ ЭТОТ ЭЛЕМЕНТ, СДЕЛАНО ДЛЯ ВЫЗОВА ОШИБКИ elem.send_keys("user") elem = driver.find_element_by_id("LoginForm_password") elem.send_keys("pass") elem.send_keys(Keys.RETURN) print('\n 1. Логинимся в систему') wait.until(EC.element_to_be_clickable((By.CLASS_NAME, 'hidden-xs'))) if __name__ == '__main__': suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(ASeleniumLogin_1)) buf = open("at_for_MATERIAL.html", 'wb') runner = HTMLTestRunner.HTMLTestRunner( stream=buf, title='Отчет по тестированию', description='Отчет по тестированию' ) runner.run(suite) 

Screen parts joba

I also found this topic: https://stackoverflow.com/

In it, a person encountered a similar problem. I will ask a stupid question, if what is described there is really true in my case, then where should EXIT XX be used in the assembly team itself in jenkins or in the script code? Thanks in advance for your reply (s)

  • `Jenkins does not show Finished: SUCCESS, despite the fact that the test itself fell \` can, on the contrary, shows? - Senior Pomidor
  • EXIT XX needs to be used in the code. try again to disable HTMLTestRunner, run the run and look at the result - Senior Pomidor
  • Now I import sys .. if __name__ == '__main__': suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(ASeleniumLogin_1)) # File buf = open("at_for_QUESTIONS_AND_PRIORITY.html", 'wb') runner = HTMLTestRunner.HTMLTestRunner( stream=buf, title='СОЗДАНИЕ И УДАЛЕНИЕ ПРИОРИТЕТА', description='Отчет по тестированию' ) ret = not runner.run(suite).wasSuccessful() sys.exit(ret) following construction: import sys .. if __name__ == '__main__': suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(ASeleniumLogin_1)) # File buf = open("at_for_QUESTIONS_AND_PRIORITY.html", 'wb') runner = HTMLTestRunner.HTMLTestRunner( stream=buf, title='СОЗДАНИЕ И УДАЛЕНИЕ ПРИОРИТЕТА', description='Отчет по тестированию' ) ret = not runner.run(suite).wasSuccessful() sys.exit(ret) like, it worked , but we still need to test - blindeStern
  • `Џа®ўҐаЄ« ЁзЁп ¬®¤ «mle ®Є®`` hints at problems with encoding) - Nick Volynkin

1 answer 1

Jenkins runs all shell scripts in -x (debug) mode and -e (exit on first error). If any test returned FAILURE, from the point of view of the script, this is an error, so the execution is completed and the whole run follows.

So solved.

 # в самом начале скрипта: set +e ... # дальше запуск тестов ... exit 0 # конец скрипта 
  • Thanks, I will try this option, but the previous one helped: ret = not runner.run(suite).wasSuccessful() sys.exit(ret) - blindeStern