This article is about program testing for Microsoft Small Basic programming language.

Testing is a important process in developing a program.  The purpose of testing is to find issues and bugs before releasing the program.  And the test cases (testing items) are better to be designed at the same time of designing the program features.  The test cases sometimes may find regression after some changes in the program.

Unit Testing

Unit testing is done in early stage of development, and tests parts of a program such as subroutines.  Unit testing is easy to make it automatically.

Following program is a sample program which has unit testing.  In this sample, Math_Hex2Dec subroutine is tested with:

  • test cases data
  • random data
' Math_Hex2Dec Unit Testing
' Version 0.2
' Copyright © 2017 Nonki Takahashi. The MIT License.
' Program ID WCS662-0
title = "Math_Hex2Dec Unit Testing 0.2"
CRLF = Text.GetCharacter(13) + Text.GetCharacter(10)
Not = "True=False;False=True;"
indent = " "
TextWindow.Title = title
TextWindow.WriteLine(title + CRLF)
testCases = "400=1024;FF=255;0d=13;10000=65536;003366=13158;"
nTest = 0
nPass = 0
' testing with test cases
index = Array.GetAllIndices(testCases)
For i = 1 To Array.GetItemCount(testCases)
  nTest = nTest + 1
  hex = index[nTest]
  TextWindow.WriteLine(nTest + ". Math_Hex2Dec(" + hex + ")")
  expected = testCases[hex]
  result = dec
' testing with LDMath and random numbers
max = 100
For i = 1 To 4
  nTest = nTest + 1
  expected = Math.GetRandomNumber(max)
  max = max * 10
  hex = LDMath.Decimal2Base(expected, 16)
  TextWindow.WriteLine(nTest + ". Math_Hex2Dec(" + hex + ")")
  result = dec
Sub Math_Hex2Dec
  ' Math | Convert hexadecimal to decimal
  ' param hex
  ' return dec
  dec = 0
  len = Text.GetLength(hex)
  _hex = Text.ConvertToUpperCase(hex)
  For ptr = 1 To len
    dec = dec * 16 + Text.GetIndexOf("123456789ABCDEF", Text.GetSubText(_hex, ptr, 1))
Sub Test_Expected
  ' param expected - expected value
  ' param result - result value
  ' param indent - indent space if needed
  TextWindow.WriteLine(indent + "Expected: " + expected)
  TextWindow.WriteLine(indent + "Result: " + result)
  If expected = result Then
    nPass = nPass + 1
    TextWindow.ForegroundColor = "Green"
    TextWindow.WriteLine("PASS" + CRLF)
    TextWindow.ForegroundColor = "Red"
    TextWindow.WriteLine("FAIL" + CRLF)
  TextWindow.ForegroundColor = "Gray"
Sub Test_Total
  TextWindow.ForegroundColor = "Green"
  TextWindow.ForegroundColor = "Gray"
  TextWindow.WriteLine(": " + nPass + "/" + nTest + CRLF)

The result will be as follows.

Integration Testing

Integration testing means to test whole program.  It is little difficult to make it automatically.

So, for integration testing, it's important to write testing procedure. Following list is a manual test cases for Shapes editor.

  1. If there are or temp.svg, remove them before testing.
  2. Draw a triangle, save as . Run and check the shape is a triangle.
  3. Draw a rectangle, save as temp.svg . Open temp.svg from GIMP and check the shape is a rectangle.
  4. Open, add an ellipse, save as . Run and check the shapes are a triangle and an ellipse.
  5. Open, delete a triangle, save as temp.svg . Open temp.svg from GIMP and check the shape is an ellipse.
  6. Open temp.svg, add a line, save as temp.svg . Open temp.svg from GIMP and check the shapes are an ellipse and a line.
  7. Open temp.svg, delete an ellipse, save as . Run and check the shape is a line.

Automatic integration testing will be done with internal macro code in the program. Icon Editor is a sample which has internal macro.  But user interface such like keyboard and mouse events must be tested manually.

See Also

Other Resources