Unit testing: Difference between revisions
Content added Content deleted
Line 90: | Line 90: | ||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |
||
All Smalltalk dialects have a testing framework included, which is typically based on the original [https://en.wikipedia.org/wiki/SUnit SUnit test framework]. |
All Smalltalk dialects have a testing framework included, which is typically based on the original [https://en.wikipedia.org/wiki/SUnit SUnit test framework]. |
||
Tests are subclasses of TestCase, and define test methods. Execution and visual presentation |
Tests are subclasses of TestCase, and define test methods. Execution and visual presentation can be within the class browser or a UnitTest runner (which are part of the system), but tests can also be executed "headless" (i.e. without UI). |
||
Obviously, this is defined in the class library, because in Smalltalk everything comes from the class library. |
|||
Typical test cases look like: |
Typical test cases look like: |
||
<lang smalltalk>test06b_MiscMath_errors |
<lang smalltalk>test06b_MiscMath_errors |
||
Line 111: | Line 113: | ||
self should:[-10 integerSqrt] raise:DomainError.</lang> |
self should:[-10 integerSqrt] raise:DomainError.</lang> |
||
When executed headless, a result object is returned from a run, which can be printed or further analyzed. |
|||
<br>For example: |
|||
<lang smalltalk>outcome := IntegerTest run. |
|||
outcome printCR. |
|||
(JSONPrinter encode:outcome) printCR</lang> |
|||
{{out}} |
|||
<pre>97 run, 97 passed, 0 skipped, 0 failed, 0 errors |
|||
{ |
|||
"name":"RegressionTests::IntegerTest", |
|||
"timestamp":"2020-12-09T04:38:58.185", |
|||
"failures": [] |
|||
}, "errors":[], "passed":[ |
|||
{ |
|||
"testCase":{ |
|||
"testSelector":"testAnyBit" |
|||
}, |
|||
"result":"pass", |
|||
"properties":{ |
|||
"endTime":"2020-12-09T04:38:58.185", |
|||
"startTime":"2020-12-09T04:38:58.185", |
|||
"collectedOutput":"" |
|||
} |
|||
... |
|||
hundreds of more lines</pre> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |