Monday, 3 March 2014

Getting started with Python | Unittest | Selenium Users

This post lets you learn the basic Python scripting using Unittest framework for Automation testing.

Create a Test_class

1| Create a module with Test_class named, "cool"
2| Now, import a class named, "Calc" from another module
3| To create a method and class from main Test_class, press "Ctrl + 1"

import unittest
from pack.calculator import Calc

class cool(unittest.TestCase):
    def test_add(self):
        calc = Calc()
        Result = calc.add(a = 4, b = 3)
        self.assertEqual(Result, 7, "Test Failed")
        print "Test PASSED"

4| Create a method, "add" in the sub_class

class Calc(object):
    def add(self, a, b):
        return a + b

5| To execute the test, press "Ctrl + F9"


  1. Thanks for the great information in your blog Selenium Training in Chennai

  2. It was very nice blog to learn about SAP HR.Thanks for sharing new things.SAP HR