Introduction to SUnit and Blackbox Testing - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Introduction to SUnit and Blackbox Testing

Description:

Class Exception and its subclasses provided for use. Can emulate try/catch block in other languages. Exceptions pass up inheritance hierarchy. ... – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 13
Provided by: Robert9
Category:

less

Transcript and Presenter's Notes

Title: Introduction to SUnit and Blackbox Testing


1
Introduction to SUnit and Blackbox Testing
  • CS2340
  • Spring 2003

2
Exception Handling in Squeak
  • Class Exception and its subclasses provided for
    use.
  • Can emulate try/catch block in other languages
  • Exceptions pass up inheritance hierarchy. If not
    handled, get default handler at Object.

3
Example
x y x7. y0. x / y on ZeroDivide
do exception Transcript show
exception description cr. 0 .
4
Example
f fFileStream fileNamed 'fred'. f
nextPutAll 'Test'. f close. on
FileDoesNotExistException do exception
Transcript show exception description. .
5
Blackbox Testing
  • Going to get the theory from 2335.
  • Treat code as a blackbox
  • Base test cases on specification
  • Two major techniques
  • Equivalence Partitions
  • Boundary Tests
  • Exhaustive testing not possible

6
Equivalence Partititions
  • Treat sets of data as same (if one test succeeds
    all tests succeed)
  • For ranges, pick one test in range, one test on
    each end.
  • For sets, pick one in set, one not in set.
  • For unique values, pick value, not value.

7
Examples
  • Must accept years between 1-2050. Test cases 0,
    1876 , 2076.
  • Passwords must be 6-8 chars long
  • Test cases ab, abcdef, abcdegujswidn
  • Leap years are divisible by four
  • Test cases 16, 99
  • Phone exchanges must not begin with 555.
  • Test cases 555, 498

8
Writing your tests
  • We could just write workspace code and DoIt over
    and over
  • Hoping that we dont ever close window
  • Checking transcript manually to ensure results
    are what we want.
  • We could write a custom class to do our test and
    result checking
  • We can use the SUnit framework.

9
SUnit
  • We will cover framework in more detail later.
  • Learn by rote
  • Derive class from TestCase
  • Create methods testXxxx
  • Use
  • self assert expr_that_evals_true
  • self deny expr_that_evals_false
  • self should block that evals to true .
  • self shouldnt block that evals to false .
  • TestRunner open.

10
Example
Assume we have a class BobO with method name
aName nameaName. name. And name
name.
testName aClass aClass_BobO new. aClass
name 'Bob'. self assert aClass name 'Bob'.
self should aClass name Bob. self deny
aClass name oBb.
TestCase subclass TestBobO
instanceVariableNames classVariableNames
poolDictionaries category Bob
Classes .
11
Key steps
  • For each real class X, have a test class TestX
    derived from TestCase
  • Decide how to test each method
  • For each method y in class X, have a test method
    testY in class TestX.
  • Run TestRunner to evaluate tests automatically
  • May use SqueakMap to download TestBrowser if
    desired.

12
M1 Questions???
Write a Comment
User Comments (0)
About PowerShow.com