hwtest
Type members
Classlikes
Provides methods to delay arbitrary code ("actions") and to execute the delayed actions later in FIFO order.
Provides methods to delay arbitrary code ("actions") and to execute the delayed actions later in FIFO order.
When delayed code is eventually executed, its resulting value will be discarded so the delayed code should be effectful.
The point of this delay is to avoid potential initialization-order bugs
inside the homework object (object hw7 extends ...
) that would otherwise
be very confusing for students. For example, a test might indirectly
depend on a val
that has not yet been initialized. Instead, the test
will delayed--invisibly to the student--to be executed inside the
main
method, after object initialization is complete.
A Reporter
(in the ScalaTest sense) that displays a .
for each
successful test case and a X
for each failed test case. For the
first few failed test cases, the complete details (including
input, expected output, and actual output) are displayed instead
of merely an X
.
A Reporter
(in the ScalaTest sense) that displays a .
for each
successful test case and a X
for each failed test case. For the
first few failed test cases, the complete details (including
input, expected output, and actual output) are displayed instead
of merely an X
.
- Value parameters:
- failureLimit
the number of failed test cases that will display full details before switching to an
X
- timeLimit
the time (in milliseconds) that a test case is allowed to run before timing out
Iterator through a string representing test data, primarily used
as input to Parser
s.
Iterator through a string representing test data, primarily used
as input to Parser
s.
Note that the iterator normally contains all the test data for all the
tests, not just the data for a single test. This "global" Src
is
maintained in hwtest.hw.
The Src
iterator is primarly used as input to Parser
s.
Note: Although Src
is conceptually an iterator implementing the
standard hasNext
and next()
methods, it does NOT inherit from
the Iterator
trait.
- Value parameters:
- text
the test data as a
String
Provides the methods the test framework needs to test functions that
take and/or return data of type A
.
Provides the methods the test framework needs to test functions that
take and/or return data of type A
.
- Companion:
- object
Provides many "given" Testable
instances for built-in types.
Provides many "given" Testable
instances for built-in types.
Provided types include
Int
,Long
,BigInt
,Double
Boolean
,Char
,String
Option
,List
,Array
Set
,Map
(fromscala.collection.immutable
)Tuple2
, ...,Tuple6
Other types can be added as needed by declaring an appropriate
Testable
instance.
Also provides a TestableGrid
instance for an array of arrays
that displays its data in a grid-like format.
- Companion:
- class
Base class for a homework.
Base class for a homework.
The code for a typical homework will begin
object hw7 extends hwtest.hw("CS123"):
...
The hw
class defines a main
method that runs all the tests,
so the homework code (object hw7
above) does not, and in fact cannot,
define a new main
because the main
method is final
.
Value members
Concrete methods
Concrete fields
The default number of failed test cases (2) for which the full details will be displayed.
The default number of failed test cases (2) for which the full details will be displayed.
Failed test cases beyond this limit will display as X
s.
The intent behind this limit is two-fold:
- Seeing full details of many failed test cases is overwhelming.
- If many failed test cases are displayed, then the user will often see the bigger failed tests instead of the smaller failed tests (assuming the test cases are arranged roughly smallest to biggest), because the smaller failed test cases may have scrolled off the screen. Yet it is usually easier to spot an error in a smaller failed test case than a bigger one.
The default length of time (500 milliseconds) an individual test case in this test is allowed to run before timing out.
The default length of time (500 milliseconds) an individual test case in this test is allowed to run before timing out.
The minimum permitted failure limit (1).
The minimum permitted failure limit (1).
Attempted use of a smaller limit will display a warning message and be converted to this limit instead
The minimum permitted time limit (50 milliseconds).
The minimum permitted time limit (50 milliseconds).
Attempted use of a smaller limit will display a warning message and be converted to this limit instead.
Of course, many functions should run much faster than 50 milliseconds, but accurately measuring the time taken by a function is a hard problem, especially on the JVM. Smaller time limits would likely lead to too many false negatives.
The intent of time limits is not for trying to enforce very fast running times, but rather for keeping the total time for a set of tests manageable.