Differences between revisions 2 and 4 (spanning 2 versions)
Revision 2 as of 2011-10-17 18:36:08
Size: 643
Editor: KaiJaeger
Comment:
Revision 4 as of 2011-10-18 06:23:12
Size: 6474
Editor: KaiJaeger
Comment:
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
|| /!\ Work in progress ||
Line 10: Line 12:
... The purpose of this class is to provide a framework for testing all the projects of the APLTree project. Only with such a framework is it possible to make changes to the test suite without too much hassle.
You might find the framework flexible enough to suit your own needs when it comes to implementing tests.
Line 13: Line 16:
...
Line 15: Line 17:
=== Terminology ===

Note that test case causing a crash are considered "broken" Test cases that do not get the expected result are considered "failing".

=== Assumptions and preconditions ===

 1. The `#.Tester` class assumes that all your tests are hosted by an ordinary namespace. All methods take a ref to that namespace as an argument.
 1. All test functions inside that namespace are expected to start their names with the string `Test_` followed by digits.
 1. The first line after the header must carry a comment telling what is actually tested. Keep in mind that later you might be in need for finding out which test cases are testing a certain method!
 1. It is assumed that you have three different scenarios when you want to run test cases with a different behaviour:
    * Run with error trapping and return a log (vector of text vectors) reporting details. Run this before checking in.
    * Run without error trapping. Use this for investigating why test cases unexpectedly fail.
    * Run "batch mode". It is assumed that those test cases that need a human being in front of the monitor are '''not''' executed when running in batch mode.
 1. Every test function must accept a right argument which is a two-item vector of Booleans:
    1. `stopFlag` (0=use error trapping)
    1. `batchFlag` (0=does not run in batch mode)
 1. Every test function must return a scalar integer with one of:
    * `0`: the test case is okay.
    * `1`: the test case failed.
    * `-1`: means the test case did not execute itself because it is not designed to run in batch mode.

== Methods ==
<<SeeSaw(section="methods", toshow="<<Show>> the methods", tohide="<<Hide>> the methods", bg="#FEE1A5", speed="Slow")>>
{{{{#!wiki seesaw/methods/methods-bg/hide

=== GetAllTestFns ===

{{{
r←GetAllTestFns refToTestNamespace
}}}
Returns the names of all test functions found in namespace "refToTestNamespace".

=== ListTestCases ===

{{{
r←ListTestCases refToTestNamespace;list
}}}

Returns the comment expected in line 1 of all test cases found in "refToTestNamespace".

=== Run ===

{{{
{log}←Run refToTestNamespace;flags
}}}
Runs all test cases in "refToTestNamespace" with error trapping. Broken as well as failing tests are reported in the session as such but they don't stop the program from carrying on.

=== RunBatchTests ===

{{{
{(rc log)}←RunBatchTests refToTestNamespace
}}}

Runs all test cases in "refToTestNamespace" but tells the test functions that this is a batch run meaning that test cases which are reporting to the session for any reason and those in need for a human being for interaction should quit silently.
Returns 0 for okay or a 1 in case one or more test cases are broken or failed.
This method can run in a runtime as well as in an automated test environment.

=== RunDebug ===

{{{
{log}←{stop}RunDebug refToTestNamespace
}}}

Runs all test cases in "refToTestNamespace" <b>without</b> error trapping. If a test case encounters an invalid result it stops. Use this function to investigate the details after "Run" detected a problem.
This will work only if you use a particualar strategy when checking results in a test case

=== RunTheseIn ===

=== Version ===

Returns version (x.y.z) and date (yyyy-mm-dd) of the class `#.Tester`

}}}}
Line 17: Line 92:
<<SeeSaw(section="samples", toshow="<<Show>> the examples", tohide="<<Hide>> the examples", bg="#FEE1A5", speed="Slow")>>
{{{{#!wiki seesaw/samples/samples-bg/hide

{{{
      )load APLTree\WinFile
Loaded....
      #.Tester.GetAllTestFns #.TestCases
 Test_001 Test_002 Test_003 Test_004 Test_005 ...
      ⊃#.Tester.ListTestCases #.TestCases
Exercise "MkDir"
Exercise "RmDir"
Exercise "Dir"
Exercise "DirX"
Line 18: Line 106:
#.Tester.Run #.TestCases
--- Tests started at 2011-10-18 07:15:25 on #.TestCases -------------------------------------
  Test_001: Exercise "MkDir"
  Test_002: Exercise "RmDir"
  Test_003: Exercise "Dir"
  Test_004: Exercise "DirX"
  Test_005: Exercise "cd"
  Test_006: Exercise "Delete"
  Test_007: Exercise "DateOf"
  Test_008: Exercise "DoesExistDir"
  Test_009: Exercise "DoesExistFile"
  Test_010: Exercise "DoesExist"
  Test_011: Exercise "GetAllDrives"
  Test_012: Exercise "GetDriveAndType"
  Test_013: Exercise "IsDirEmpty"
  Test_014: Exercise "ListDirXIndices"
  Test_015: Exercise "ListFileAttributes"
  Test_016: Exercise "YoungerThan"
  Test_017: Exercise "GetTempFileName"
  Test_018: Exercise "GetTempPath"
  Test_019: Exercise "WriteAnsiFile" and "ReadAnsiFile"
  Test_020: Exercise "CopyTo"
  Test_021: Exercise "MoveTo"
  Test_022: Exercise "ListDirsOnly"
  Test_023: Exercise "CheckPath"
  Test_024: Exercise "PWD"
  Test_025: Exercise "IsFilenameOkay"
  Test_026: Exercise "IsFoldername"
 ----------------------------------------------------------------------------------------------
   26 test cases executed
   0 test cases failed
   0 test cases broken
Line 19: Line 139:
== History ==
For a full version history: [[Tester/History|History]]
      ⎕←↑#.Tester.RunBatchTests #.TestCases
0

 4 #.Tester.RunDebug #.TestCases ⍝ Stop at test case number 4
--- Tests started at 2011-10-18 07:16:03 on #.TestCases -------------------------------------
  Test_001: Exercise "MkDir"
  Test_002: Exercise "RmDir"
  Test_003: Exercise "Dir"

Run__[61]
⍝ Now you can trace into the forth test case.
}}}

}}}}

== Project Page ==

For bug reports, future enhancements and a full version history see [[Tester/ProjectPage]]
Line 27: Line 163:
== Download ==

Tester

(Hide table-of-contents)

/!\ Work in progress

Tester is part of the CategoryAplTree project.

Overview

The purpose of this class is to provide a framework for testing all the projects of the APLTree project. Only with such a framework is it possible to make changes to the test suite without too much hassle. You might find the framework flexible enough to suit your own needs when it comes to implementing tests.

Details

Terminology

Note that test case causing a crash are considered "broken" Test cases that do not get the expected result are considered "failing".

Assumptions and preconditions

  1. The #.Tester class assumes that all your tests are hosted by an ordinary namespace. All methods take a ref to that namespace as an argument.

  2. All test functions inside that namespace are expected to start their names with the string Test_ followed by digits.

  3. The first line after the header must carry a comment telling what is actually tested. Keep in mind that later you might be in need for finding out which test cases are testing a certain method!
  4. It is assumed that you have three different scenarios when you want to run test cases with a different behaviour:
    • Run with error trapping and return a log (vector of text vectors) reporting details. Run this before checking in.
    • Run without error trapping. Use this for investigating why test cases unexpectedly fail.
    • Run "batch mode". It is assumed that those test cases that need a human being in front of the monitor are not executed when running in batch mode.

  5. Every test function must accept a right argument which is a two-item vector of Booleans:
    1. stopFlag (0=use error trapping)

    2. batchFlag (0=does not run in batch mode)

  6. Every test function must return a scalar integer with one of:
    • 0: the test case is okay.

    • 1: the test case failed.

    • -1: means the test case did not execute itself because it is not designed to run in batch mode.

Methods

Show the methods

GetAllTestFns

r←GetAllTestFns refToTestNamespace

Returns the names of all test functions found in namespace "refToTestNamespace".

ListTestCases

r←ListTestCases refToTestNamespace;list

Returns the comment expected in line 1 of all test cases found in "refToTestNamespace".

Run

{log}←Run refToTestNamespace;flags

Runs all test cases in "refToTestNamespace" with error trapping. Broken as well as failing tests are reported in the session as such but they don't stop the program from carrying on.

RunBatchTests

{(rc log)}←RunBatchTests refToTestNamespace

Runs all test cases in "refToTestNamespace" but tells the test functions that this is a batch run meaning that test cases which are reporting to the session for any reason and those in need for a human being for interaction should quit silently. Returns 0 for okay or a 1 in case one or more test cases are broken or failed. This method can run in a runtime as well as in an automated test environment.

RunDebug

{log}←{stop}RunDebug refToTestNamespace

Runs all test cases in "refToTestNamespace" <b>without</b> error trapping. If a test case encounters an invalid result it stops. Use this function to investigate the details after "Run" detected a problem. This will work only if you use a particualar strategy when checking results in a test case

RunTheseIn

Version

Returns version (x.y.z) and date (yyyy-mm-dd) of the class #.Tester

Examples

Show the examples

      )load APLTree\WinFile
Loaded....
      #.Tester.GetAllTestFns #.TestCases
 Test_001  Test_002  Test_003  Test_004  Test_005 ...
      ⊃#.Tester.ListTestCases #.TestCases
Exercise "MkDir"                           
Exercise "RmDir"                           
Exercise "Dir"                             
Exercise "DirX"                          
...
#.Tester.Run #.TestCases
--- Tests started at 2011-10-18 07:15:25  on #.TestCases -------------------------------------
  Test_001: Exercise "MkDir"
  Test_002: Exercise "RmDir"
  Test_003: Exercise "Dir"
  Test_004: Exercise "DirX"
  Test_005: Exercise "cd"
  Test_006: Exercise "Delete"
  Test_007: Exercise "DateOf"
  Test_008: Exercise "DoesExistDir"
  Test_009: Exercise "DoesExistFile"
  Test_010: Exercise "DoesExist"
  Test_011: Exercise "GetAllDrives"
  Test_012: Exercise "GetDriveAndType"
  Test_013: Exercise "IsDirEmpty"
  Test_014: Exercise "ListDirXIndices"
  Test_015: Exercise "ListFileAttributes"
  Test_016: Exercise "YoungerThan"
  Test_017: Exercise "GetTempFileName"
  Test_018: Exercise "GetTempPath"
  Test_019: Exercise "WriteAnsiFile" and "ReadAnsiFile"
  Test_020: Exercise "CopyTo"
  Test_021: Exercise "MoveTo"
  Test_022: Exercise "ListDirsOnly"
  Test_023: Exercise "CheckPath"
  Test_024: Exercise "PWD"
  Test_025: Exercise "IsFilenameOkay"
  Test_026: Exercise "IsFoldername"
 ----------------------------------------------------------------------------------------------
   26 test cases executed
   0 test cases failed
   0 test cases broken

      ⎕←↑#.Tester.RunBatchTests #.TestCases
0

 4 #.Tester.RunDebug #.TestCases  ⍝ Stop at test case number 4
--- Tests started at 2011-10-18 07:16:03  on #.TestCases -------------------------------------
  Test_001: Exercise "MkDir"
  Test_002: Exercise "RmDir"
  Test_003: Exercise "Dir"

Run__[61]
⍝ Now you can trace into the forth test case.

Project Page

For bug reports, future enhancements and a full version history see Tester/ProjectPage

Version Information

Original author:

KaiJaeger

Responsible:

KaiJaeger

Email:

kai@aplteam.com


CategoryAplTree

Tester (last edited 2018-03-03 11:47:23 by KaiJaeger)