Active TopicsActive Topics  Display List of Forum MembersMemberlist  CalendarCalendar  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin


 One Stop Testing ForumTypes Of Software Testing @ OneStopTestingUnit Testing @ OneStopTesting

Message Icon Topic: UnitTest Lesson # 01

Post Reply Post New Topic
Author Message
tanushree
Senior Member
Senior Member
Avatar

Joined: 04Apr2007
Online Status: Offline
Posts: 2160
Quote tanushree Replybullet Topic: UnitTest Lesson # 01
    Posted: 04Oct2007 at 1:05am
For all members!
Identify Inputs For Unit Testing - Part I
Please feel free to participate. This is a pilot run of interactive training. Please read all.
So please do jump in here and provide your test cases along with why. I or someone will try to give review comments/questions once weekly along with a new lesson.

Purpose of this exercise: Identify and list test cases.

Source code is in blue along with code commentary. That does not mean it is starved of oxygen.
--------------------------------------------------------
Code:

' Begin COPY POINT
'

' This VBScript function tests to see if a value passed is an even value.
' It returns the result of the value test in the name of the function itself = “IsEven”
' Initializes the value of “IsEven” to Boolean FALSE (Zero)
' This is intended to simplify the IF / END IF Block
' The MOD operator simply says Divide ValueIN by the value to the right of MOD (2) and capture the remainder.
' If the remainder is Zero we can assume an even number - True.
'-----------------------------------------------------------------------------------

Function IsEven( ValueIN)
IsEven = FALSE
If (ValueIN Mod 2) = 0 Then
IsEven = TRUE
End If
End Function

'-----------------------------------------------------------------------------------
'----------------- MAIN ---------------------------------------------------
' Main program to call “IsEven” It’s only job is to do three things in one statement:
' 1. Put up a message box, after
' 2. Passing a value to “IsEven”, and
' 3. Capturing the result of the call to the “IsEven” function
'
msgbox IsEven (23) '' <- Change this value to experiment
'
'------------------ END MAIN --------------------------------------------------

' END COPY POINT



'- Copy/paste from top Begin COPY POINT to END COPY POINT
above, to a file and not beyond. See further below for filing instructions.
'
' Why VBScript? You can run it on your desktop and experiment
' How?
' 1. Copy/paste the code into a new text file
' 2. Change the name to MyUnitTestLesson1.vbs
' 3. Double-click the icon to execute
' 4. Right-mouse over the file icon – select edit to edit it.
' 5. Change the numeric value in the msgbox IsEven call
' 6. Save and re-run

This assumes that “unit” means one tests to the visible source code. For
Our purposes “unit” is the same as “module” or “component”. This type of
testing is unit testing and is also known as white-box, glass-box, or clear-box.

[] What are some test cases you can come up with?
[] How would you prove that the function does what it suggests?
[] How would you expose it’s defects?

Hint! Since there are no hard requirements, might there be some
implied requirements as suggested by the name and implementation?

[] Might there be defects with respect to the implied requirements?



Post Resume: Click here to Upload your Resume & Apply for Jobs

IP IP Logged
vragavender
Newbie
Newbie


Joined: 10Jan2008
Location: India
Online Status: Offline
Posts: 1
Quote vragavender Replybullet Posted: 05Feb2008 at 10:11pm
super super !this is very helpful!
now i understand wat is unit testing, i want an exaple like for integration and system testing , and give me some vbs programs to understand please
thanks
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.061 seconds.
Vyom is an ISO 9001:2000 Certified Organization

© Vyom Technosoft Pvt. Ltd. All Rights Reserved.

Privacy Policy | Terms and Conditions
Job Interview Questions | Placement Papers | Free SMS | Freshers Jobs | MBA Forum | Learn SAP | Web Hosting