Archive

Posts Tagged ‘Programming’

Automation testing contd

September 16, 2010 Leave a comment

Before going further lets understand the testing steps:
Unit testing
—————–
This type of testing tests individual application objects or methods in an isolated environment. It verifies the smallest unit of the application to ensure the correct structure and the defined operations. Unit testing is the most efficient and effective means to detect defects or bugs. The testing tools are capable of creating unit test scripts.
Integration testing
——————-
This testing is to evaluate proper functioning of the integrated modules (objects, methods) that make up a subsystem. The focus of integration testing is on cross-functional tests rather than on unit tests within one module. Available testing tools usually provide gateways to create stubs and mock objects for this test.
System testing
——————
System testing should be executed as soon as an integrated set of modules has been assembled to form the application. System testing verifies the product by testing the application in the integrated system environment.
Regression testing
—————–
Regression testing ensures that code modification, bug correction, and any postproduction activities have not introduced any additional bugs into the previously tested code. This test often reuses the test scripts created for unit and integration testing. Software testing tools offer harnesses to manage these test scripts and schedule the regression testing.

Usability testing
—————–
Usability testing ensures that the presentation, data flow, and general ergonomics of the application meet the requirements of the intended users. This testing phase is critical to attract and keep customers. Usually, manual testing methods are inevitable for this purpose.
Stress testing
————–
Stress testing makes sure that the features of the software and hardware continue to function correctly under a predesigned set and volume of test scenarios. The purpose of stress testing is to ensure that the system can hold and operate efficiently under different load conditions. Thus, the possible hardware platforms, operating systems, and other applications used by the customers should be considered for this testing phase.
Performance testing
—————–
Performance testing measures the response times of the systems to complete a task and the efficiency of the algorithms under varied conditions. Therefore, performance testing also takes into consideration the possible hardware platforms, operating systems, and other applications used by the customers.

Programming Language C : Part 3

April 27, 2009 2 comments

Last day, I’d ended on the basic structure of the C Programming Language. Today, we shall start to do real programming. It is really fun.

Ok. Lets do a small program to print your name:

c1

This program will give you output like: c2

Now, we shall move to DATA Types.

As we know, there are many types of data in our real world. For example, the Integers, the Floating point numbers, Characters etc.

In case of C, there also exist all of them. In case, we want to use them, we need to “INITIALIZE” them to the Compiler. The method is like this:

c3Here we can see, “int a” declares an integer called ‘a’ without any value. But, “int b = 5” declares an integer called ‘b’ with a value 5 assigned in it. Similarly for floating point numbers, ‘float’ is used and for characters, “char” is used. All these ‘int’ or ‘float’ or ‘char’ are called “keywords” in C.

We shall look further more keywords in C:

c4

All these keywords have their own meanings and jobs to do. We shall look them further, while we will need them in future.

Now, there is a question. I know, I can use int as a keyword to mean the integers. But, how long that integer can be? Int x = 1234567891011121314151617…..??? There should be a limit of this.

char     => a single byte, capable of holding one character in the local character set

int        => an integer, typically reflecting the natural size of integers on the host machine

float     => single-precision floating point

double =>  double-precision floating point

In addition, there are a number of qualifiers that can be applied to these basic types. short

and long apply to integers:

short int sh;

long int counter;

The word int can be omitted in such declarations, and typically it is. The intent is that short and long should provide different lengths of integers where practical; int will normally be the natural size for a particular machine. short is often 16 bits long, and int either 16 or 32 bits. Each compiler is free to choose appropriate sizes for its own hardware, subject only to the the restriction that shorts and ints are at least 16 bits, longs are at least 32 bits, and short is no longer than int, which is no longer than long.  The qualifier signed or unsigned may be applied to char or any integer. unsigned numbers are always positive or zero, and obey the laws of arithmetic modulo 2n, where n is the number of bits in the type. So, for instance, if chars are 8 bits, unsigned char variables have values between 0 and 255, while  signed chars have values between -128 and 127 (in a two’s complement machine.) Whether plain  chars are signed or unsigned is machine-dependent, but printable characters are always positive.  The type long double specifies extended-precision floating point. As with integers, the sizes of floating-point objects are implementation-defined; float, double and long double could represent one, two or three distinct sizes.

Python: Bult-in Functions for Numeric types

April 24, 2009 2 comments

Python has some built-in functions for working with numeric types. Some of them are described below: ———–

Function Name

Descriptions

Code Example

abs

The abs(x) function takes the absolute value of any integer, long integer or floating point number.

When applied to a complex number, the function returns the magnitude of the number, which is distance from that point to the origin in the complex plane.

>>> abs(-5.0)

5.0

>>> abs(-2)

2

>>> abs(5+2j)

5.3851648071345037

coerce

The coerce(x,y) function applies numeric conversion rules(described below the table) to two numbers and return them as tuple.

>>coerce(5,2.5)

(5.0,2.5)

>>coerce(5.5,5+2j)

(5.5+0j,5+2j)

divmod

The functions divmod(a,b) performs long division on two numbers and returns the quotient and remainder.

>>> divmod(5,2)

(2, 1)

>>> divmod(5.5,2.5)

(2.0, 0.5)

pow

The functions pow(x,y[,z]) performs power operation.

As usual, Python coerces the two numbers to a common type if needed. If the resulting type can’t express the correct result then python will show an error message.

An optional third argument to pow specifies the modulo operation to perform on the result.

>>> pow(2,3)

8

>>> pow(2,-1)

0.5

>>> pow(2,5,10)

2

For all the built-in functions and there definitions, please visit this link:
http://docs.python.org/library/functions.html

Numeric Conversion Rule:

  1. If one of the numbers is a complex number then convert the other two a complex number too.
  2. If one of the numbers is floating point number then convert the other to floating point.
  3. If one of the numbers is a long integer then convert the other to a long integer. (Not applicable for Python 3.1)
  4. No previous rules applied, so both are integers, and Python leaves them unchanged.

C Programming: Part 2

April 16, 2009 1 comment

Hello friends! After a long time, I am back with the Programming Language C.

In regard of the last post and the comments posted by our readers, I must insist you trying all of these in Linux / UNIX also. In Linux / UNIX, you don’t need any 3rd party software line ‘Turbo C’ in Windows. In the OS itself, the ‘gcc’ (GNU’s C Compiler) compiler is preloaded. You just need to call the ‘gcc’ and then compile/run the program.

Now, we will go into the C programming!

Before everything, we will write a C program first.

Windows: Open Turbo C è write this code.

Linux / UNIX: Open terminal ècreate ‘hello.c’ in the VI editor è write this code.


#include <stdio.h>

#include <conio.h>

int main()

{

printf(“ Hello World.”);

getch();

return 0;

}

Now, we will look, what are these lines signify:

Line 1 and 2: These are called “Pre-Processor Directives”. We include these “.h” files rather “header files” in our program to use some of their properties. These properties are called “Functions”. Here, in line 5, 6 and 7, you will see some “printf”, “getch” and “return”…these are those Functions. The “printf” and “return” functions are from the header file “stdio.h” (the ‘stdio’ means STANDARD INPUT OUTPUT and ‘conio’ means CONSOLE INPUT OUTPUT) and the “getch” is from the header file “conio.h”. Remember, other than these Functions, we ourselves can also write Functions as we wish.

Line 3: This line indicates the ‘Return type’ and ‘Name’ of a user written function (as I’d said in last paragraph). Now, to know what is ‘return type’ needs some more knowledge in C. So, we will discuss that later. Now, ‘name’. Here as we can see, after the ‘return type’ called ‘int’, there is the name of this function “main”. Now, a question arises, why ‘main’? The reason is, in any C program, there may exist more than 1 function and all of them are controlled by 1 function. Now, to get rid of the question, among those functions, which one is the 1st one, that controls other functions? The answer is: the main function. It’s like the main door of a building. After traversing through it, you can go anywhere in the building. So, here no other function exists, hence, the main door is the ‘main’ function.

Line 4 and 8: You can see these are nothing but, an opening parenthesis and a closing parenthesis. This opening means the starting of any function and closing means the closing of the same.

Line 5, 6 and 7: “printf” is a function, whose job is to print something. Inside the two brackets, there are two upper commas. Inside those ‘upper commas’, if you write some thing, that will be shown to you in the monitor when that program will run. Similarly, “getch” and “return” has some jobs to do. These jobs will be cleared to us when we will have some more knowledges in C.

One more thing, if you have noticed, you can see there is a semicolon (;) after every line inside the main function. This semicolon indicates the ‘End of the Line’.

Now, to compile:

Windows: (in Turbo C) F2 (to save the program) è Alt + F9.

Linux / UNIX: (after saving the program in VI editor) gcc -c -a hello.c

Now, to Run:

Windows: (after compilation) Ctrl + F9.

Linux / UNIX: (after compilation) ./hello.c

Python: Variables, Numeric Types and Operators

April 8, 2009 Leave a comment

Python offers four different kinds of numbers with which you can work:integers, long numbers (or longs), floating-point numbers (or floats), and imaginary/complex numbers.

We are familiar with Integer, Long or Floating point Numbers. The new type is Imaginary/Complex number. The imaginary number behaves very much like a float, except that it cannot be mixed with a float. When you see an imaginary number, it will have the letter j trailing it.

Note: Python 2 had separate int and long types for non-floating-point numbers. An int could not be any larger than sys.maxint, which varied by platform. Longs were defined by appending an L to the end of the number, and they could be, well, longer than ints. In Python 3, there is only one integer type, called int, which mostly behaves like the long type in Python 2. Since there are no longer two types, there is no need for special syntax to distinguish them.

To determine the type of a number, you can use a special function that is built into Python, called type. When you use type, Python will tell you what kind of data you’re looking at. Let’s try this with a few examples.

code5In the above examples, we use type() function to determine the type of 2 different numbers: integer, float and complex.

Format Specifiers:

Int: %d

Float: %f

Exponential (For large numbers): %E

Manipulating the Numeric Datatypes:

We can use most of the Python’s operators when working with Numeric data types. the following table lists the operators and how they behavewith numeric types:

code6

Next Post: Useful functions in Python

The Programming Language – C


Hello and Welcome to all our readers.

This is Jayanta here. I will be posting topics / tutorials on ‘C’ programming Language.

Before everything, at first, I want to share a brief history of C with you.

This ‘C’ was written by Dennis Ritchie for the OS called “Unix“. While, he was developing Unix, he realized that, there should be a good programming language, so, he developed it.

The simple naming convention behind “C” is, prior to C, there was a language called “B”. B actually was the abbr. of ‘BCPL‘. So, as a casual naming convention, after B, it was named C !!

Before Starting C, I want to share some resources about C.

The software, where you want to write , edit ,run C programs (these softwares are generally called IDE – Integrated Development Environment; hence, I’ll also call IDE..), you need an IDE. Here is a link of a good IDE. Use this one only. IDE

[To install the IDE, just copy the downloaded file to your C drive. Double click it. It will take care of itself.]

And now, books. For books I would prefer E. Balaguruswamy or Y. Kanitkar.

So, this much for today.. Have a good day..

Python: Experimenting with Variables and Expressions

March 30, 2009 Leave a comment

Python understand the standard logical operators including + , – , * , /. Take the following example:


>>> 8/2
4
>>> 5+4*6
29

Python uses operator precedence rules to decide what operation to do first. For this reason the 2nd example results 29 rather than 54. We can use parenthesis to control the order of operation:—

>>> (5+4)*6
54

Variables:

Variables can be used to hold values over time. The following code computes the total number of student in a school taking values from Morning Section and Day section:–

>>> Tot_morn=550
>>> Tot_day=800
>>> Tot_student=Tot_morn + Tot_day
>>> Tot_student
1350

A variable is always a reference to a value. Variables do not have types but objects do.

[Note: Python is a loosely typed language. The same variable name can be used to store integer at one time and string at another time. ]

Python doesn’t require variable declaration. But we can’t access a variable until we assigned a value to it. If we try to access a undefined variable, the following exception will come up:–
>>> print(A)
Traceback (most recent call last):
File “<pyshell#0>”, line 1, in <module>
Print(A)
Nameerror: name ‘A’ is not defined

In the above example we have tried to print the contents of the undefined variable A.
In Python, errors are represented by exception object that surrounding the code can handle.

Python is case sensitive. The two variables a1 and A1 are different.