Skip to main content

Posts

Showing posts with the label Automation

SVN commands you must know as an Automation Engineer

In the course of automation and continuous integration , you will someday come across a stage where you have to perform svn operations . And obviously, using command line (forget fancy UIs to do your business) using command line. And then you will have to start digging in,  which will take a substantial amount time ...believe me. This happened with me recently, and I swore to myself, I cannot repeat this search and rescue operation.
The basic svn operations you must be using everyday are:  Checkout  Export  Add files Commit Info Update  Get properties Set properties log  listLets say, you are automating a testing activity. You basic steps must be:  Get the firmware to be tested (from svn or some repo) Get test code (again from repo) Run your test Commit test results into a Tag or send a report For 3 of above tasks,  you are going to need to use a lot of svn commands
Export or Checkout ?
Before you start, you must decide to checkout or export your repositories.  If you need to commit a…

Art of Unittest writing : Auto-generation of unit test cases

How to auto create test cases with minimum coding  Lets say , you want to run a series of test cases that undergo similar kind of testing  . but you need to generate different test cases for each comparison (or whatever test procedure you are using).

So imagine. We want to test a function. A function that accepts two variables, and an operator for comparison. Here's our test function:

def _test_func(self, a, b, exp, operator):
        ans = 0
        exec("ans = %d %s %d" % (a, operator, b))
        self.assertEqual(ans, exp)

We want to test above function with various inputs....And...we want each scenario as a test case...You might need it for test report or something...


importunittestfromcollectionsimportnamedtupleclassTestAuto(unittest.TestCase):defsetUp(self):passdeftearDown(self):pass# Adder function to add test casedef_add_test(cls,generator):forfunc,name,doc,a,b,exp,operatoringenerator():test=lambdaself,a=a,b=b,expected=exp,oper=operator,func=func:func(self,a,b,expec…