Reputation: 1809
I wrote the test cases with such structure:
import unittest
....
url = TestObjects.host #url host
class AuthInitial(unittest.TestCase):
def setUp(self):
self.driver = TestObjects.driver #start browser
def test_name(self):
some test_logic in browser
def tearDown(self):
self.assertEqual()
self.driver.close()
if __name__ == '__main__':
unittest.main()
when I run test by nosetests command I got an error (winerror-10061)
how to properly start tests? Do I need close and open browser each time?
Upvotes: 0
Views: 75
Reputation: 280
So, the setUp() and tearDown() methods are called before and after (respectively) each of the different test functions. In this case, you have one of these (test_name). If you don't have something that needs to be created and destroyed to test your code, most likely you can just include the code snippets in the testing functions as well.
That being said, let's look at the test you have. Right now the test_name function is not doing anything and instead you have self.assertEqual() in the tearDown method. You should move the self.asserEqual() into the test_name function. After this you need to provide some arguement to the assertion you want to test:
self.asserEqual(testobject.property, "Foo")
for example. You need to pass in something and compare it to what you expect. In this particular case I'm seeing if testobject.property is the same as Foo. If this is the case it will carry on. If not, the unittest framework will print out a report commenting they are not the same.
Hopefully that helps.
Upvotes: 1