I am currently testing my website with Selenium, Python and nosetests. Everything works fine for success tests, I got a problem on failure tests (I have never test with Python / Selenium / Nosetest so ...). For the following test :
@unittest.expectedFailure
def test_connection_failure(self):
# Fill the username with the login only
self.driver.find_element_by_id('form_identifiant').send_keys(test_login)
# Send the form
self.driver.find_element_by_id('form_submit').click()
# Check the landing URL
page_url = self.driver.current_url
self.assertEqual(page_url, page_home)
I am testing a very simple case : when you enter only a login, you can't connect to the website. So I do except a failure when I compare my current page URL and the page where I should be if the login / password couple were correct.
I got the following message from nosetests prompt :
[root@localhost AppGestion]# nosetests ConnectionTests.py
/usr/lib64/python2.7/unittest/case.py:380: RuntimeWarning: TestResult has no addExpectedFailure method, reporting as passes
RuntimeWarning)
I just don't understand this error. I found the "addExpectedFailure" method on the net but didn't found how to use it, where to put it ... I would like to because the test is just skipped by nosetest actually.
Any clues ?