Rants On Software

pure tech – zero yada yada

what is test framework, how it works?

May 19th, 2012

What is framework?

In definition, framework is a set of common and prefabricated software building blocks that programmers can use, extend or customize for specific computing solutions. With frameworks developers do not have to start from scratch each time they write an application.

Bottom line, reusing the work and avoid reinventing the wheels.

So that definition is for developers, what it has to do with us software testers?

DESIGNING TEST FRAMEWORK

Test framework applicable for both computer assisted testing as well as manual test efforts, but majority of it use with computer assisted testing.

Example, you have a contact form that will be embedded to a website for testing, and you have another user enrollment form to be tested.

Both forms have few common items like first name, last name, email id, phone number. Probably you got the point already, if you can write a common test cases to test these common items, say you have some 100 modules to be tested and you have same common items across these 100 modules, chances are you will write repeated tests, the framework concept is to write tests for these common items and reuse it, this approach is very useful when we do automate the tests, example when we write tests for the items and used across modules, those automated tests finds bugs and get fixed, chances are the layout or working has been modified, if we didn’t follow these framework concept we might re write the entire automation again to accommodate the changes, if we have frameworks in place changes can be made at the common place and tests are back in place and ready to test the changes.

python code to copy content from source file and write to a new file

May 8th, 2012

python code to copy content from source file an

 

d write to a new file

python: create new file and write content for the file

May 8th, 2012

Python code to create a new file and enter contents for the created new file.

python: read content from the file

May 8th, 2012

Python code to read the content from the file and print in the command prompt.

please comment and let us know if this can be done any other way.

python temperature convertor between Celsius and Fahrenheit

April 19th, 2012

 

#python – words and symbols used and their purposes

April 18th, 2012

Solution for the Exercise 22: Learn Python The Hard Way

 

symbol

usage and purpose

#

used for commenting, anything followed are ignore by the compiler, one line comments only.

“”"
multi line comments
“”"

“”" is used to denote start of multi line comments and ends with the same “”"

=

is assignment operator
eg: A = 100

print

this will print everything followed by print
eg:

  1. print “text”
  2. print A #where A need to be defined
  3. print “text”,A
  4. print A,”text”
  5. print “show %s  and %s in screen” (A,B)
  6. print “”" multi lined text  can be printed between this triple quotes”"” 

-

will do minus

+

will do addition

*

will do multiplication

/

will do divide

<

less than

>

greater than

<=

less-than-equal

>=

greater than equal

variables

is reserved memory location to store values
eg:

  1. variable1 = 100
  2. varibale2 = “string” 
  3. print variable1
  4. print variable2
  5. variableA=variableB+variableC

strings

string is the continuous set of characters provided between quotes to the variables. 

eg: 

  1. variable = ‘string text’
  2. print variable #prints complete string
  3. print variable[0] #prints first character of the string
  4. print variable[2:5] #prints character starting from 3 to 6th
  5. print variable[2:] #prints character starting from 3
  6. print variable * 2 #prints characters two times
  7. print variable + “TEST” #prints characters plus the word TEST

%d
%s
%r
%f

string formating operation 

  1. %d – integer decimal

  2. %s – string

  3. %r – string

  4. %f – float with decimal

\t

will add tab space

\
\\

will add escape sequence eg to use ‘i am 5\’8 tall’ the single quote between the statement is ignored
adding two slash will escape one slash and still print the other

\n

will give a new line

\b

will give backspace

raw_input()

will get input for the assigned variable
eg:
name = raw_input()

raw_input(“prompt: “)

will get input for the assigned variable but it will show a prompt
eg: name = raw_input(“name: “)

from sys import argv
script, name, age = argv

here we are importing “argument” from the module “sys”
and instructing script name, name and age are the arguments will be supplied

openfile = open(filename)

this will open the file name assigned for the filename variable and store in the openfile variable. 

openfile.read()

it will read the content of the file opened in openfile variable, see above.

print openfile.read() 

to print the above read file content

open(filename,’a') 

just above specified but ‘a’ will make this file appendable when we write new content to the file

open(filename,’w')

same as above except using ‘w’ will overwrite the content with new content. 

openfile.truncate()

once we have opened a file as specified above and using the variable and truncate method will remove the contents of the file

openfile.write(variable)

it will write the content stored in the variable to the openfile

openfile.close()

it will close the open file, so the file is released from the file operation. 

from os.path import exists

here we are importing exists from os.path module, what it really does is, it is checking if the file exists, returns true is exist. 

output = open(to_file, ‘w’)
output.write(indata)

it will open the file it write mode and 
it will write the indata content to the file open at output variable.

def 

define a function

def print_one(arg1):
print “arg1 : %r” %arg1
print_one (“one”)

we’re defining a function “print_one” which will take one argument provided,
argument is printed here
argument for the function is supplied here

seek(0)

it will place the seek/cursor position

readline()

it will read the number of lines


 

How to test software ?

March 16th, 2012

The purpose to test the software is to ensure that it works perfectly and as intended.

 

There are several levels of testing just as there are several approaches to testing. It is the levels that will ensure utmost quality, so let us begin with the levels first.

 

We write software based on requirements. Who would write software without a purpose? The purpose would be the milestone for the software to meet, and that milestone should be met without any glitches and troubles for either the software itself or for the user. Software testing addresses the major concerns that the software being developed has met the milestone and addresses all reasonable user behavior.

 

It is an art to have a clearly defined purpose for the software. It is based on this clearly defined purpose that software is designed. It is at the level of defining the purpose that the business or the product owner will test the purpose itself.  Let us assume a software application to develop a calculator application. The business owner may not see the need of another calculator application when scores are already either making their mark or struggling in the market. However, if he has a well-defined USP for the new software, he might as well take the plunge to reinvent the wheel, so to say.

 

Once a purpose is determined, the software enters the design phase. A technical architect or equivalent will design the software based on the clearly defined purpose. A quality architect or equivalent will then verify that the design is aligned properly with the purpose and all features are covered in the design.
The design, after being vetted for quality moves to the hands of a software developer. If required, the design is split into various modules and developers simultaneously working on these modules independently. Each of these modules, by itself, has a clearly defined sub-purpose. The modules, once integrated, should dovetail into the main purpose. An apt analogy would be the manufacture of a car. The sub-purpose here would be the individual parts of the car and the purpose would be the car itself.

 

Just like a car manufacturer would like to test each part to ensure it meets the requirements of the overall purpose of a whole car, we need to test each module of the software to ensure it meets the sub-purpose assigned. This level of software testing, where each module is tested is called unit testing, and is one level in the testing ladder.

 

Once individual modules have been developed and unit tests confirm that they indeed meet the requirements set out for the module, the software architects assemble each of these modules and run quality tests to confirm that the software works as a whole. Taking another analogy, it is possible that the gas tank in a car is tested vigorously and so is the cap for the tank. But if the cap is either too small or too large to properly perform the act of closing the gas tank, the car cannot be manufactured. This level of testing in a software application is called integration testing and is the next step in the testing ladder.

Now that we are done with assembling the bits and testing the two and three pieces together, we move on to test the software as a whole. Or, simply put, take the car on a test drive. In this phase, we just don’t test to see if the software works. We test the software to see if it is working, if it meets the clearly defined purpose, and behave just exactly as the user would want it to. Of what use is a software if it does not behave as the user would want, even though it meets the purpose. You don’t want your car turning right when you turn the steering wheel left, right? Because a piece of software is to be used by a user and it needs to be usable by a user, the emphasis at this stage of testing is more on user behavior. This lays even more emphasis on the first two steps of the testing ladder, the unit testing and integration. This third step on the testing ladder is called system testing, and it is imperative that the first two steps of the ladder are negotiated properly without any stumble for this stage to be successful.

 

Is it just that we climb three steps of the ladder and certify that our software is good to go and hitch-free? Not at all. Like we test a car to see what the maximum load it can bear and continue to run without stalling, every software application needs to be tested for the maximum load it can handle. An application can probably work fine if it has 50 people working on it simultaneously. And, probably slow down when the user count reaches 60. It might even crash if the 61st user is logged on to use the software. We need to determine what optimal load the software can take based on the design and the user requirements and run a test incrementing the load gradually till the software crashes. We can determine the crash point at the maximum load that the software is comfortable performing as expected. This is the fourth step and is called load testing, or stress testing. However, not all applications may require load testing to be certified as successful in meeting the clearly defined purpose.

 

You might probably not have learnt how to test, drive, or test drive a car, but software? Probably yes, there’s all to software testing.

—-

Thanks to my friend Sridhar Joshi for beautifully editing this article for me.

explain “from sys import argv” in english #python

March 12th, 2012

in the following python code:

i could not understand what this first line really doing "from sys import argv" upon googling i found the answer, what i learnt is:

from sys import argv - is saying "from" the module "sys" import "argv" for the current program, so that we would be able to refer "argv" in our program.

in next line “script, filename = argv“ we are telling python how we will be providing argument in command prompt, that is “python script.py test.txt”

hope this helps.

what is the difference between argv and raw_input? #python

March 12th, 2012

when i use argv in the code i should provide argument in the prompt before i start executing the program, whereas in raw_input i can actually provide the input at the runtime, that is, if i want to collect dynamic entry like "what is the current time" then raw_input would be good, but if my code just require me to enter the date for the day, i may provide through argv itself.

so we will make sure our program wont wait for anything.

raw_input is like a pause button for the program, it will wait till the input is provided and argv just got the requirement input upfront in the command prompt itself and get the work done. so we can go do some tweet update meantime. :)

hope this explains the difference between argv and raw_input.