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 comment:

  1. Aximtrade Mt4 Download Is The Foreign Exchange Trading Platform Of Choice For Over 100,000 Investors Around The World. It's The Place To Trade Forex And Cfds On Global Markets, With Access To A Huge Range Of Assets And Features All In One Place.

    ReplyDelete