Print Page | Close Window

UnitTest Lesson # 01

Printed From: One Stop Testing
Category: Types Of Software Testing @ OneStopTesting
Forum Name: Unit Testing @ OneStopTesting
Forum Discription: Discuss All that is need to be known about Unit Software Testing and its Tools.
URL: http://forum.onestoptesting.com/forum_posts.asp?TID=2660
Printed Date: 18Dec2024 at 4:12pm


Topic: UnitTest Lesson # 01
Posted By: tanushree
Subject: UnitTest Lesson # 01
Date 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?



Replies:
Posted By: vragavender
Date 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



Print Page | Close Window