In a terminal or command line navigated to your project folder:
npm install expect.ahk
In your code only the file export.ahk needs to be included:
#Include %A_ScriptDir%\node_modules
#Include expect.ahk\export.ahk
expect := new expect()
testVar := 2 + 2
expect.equal(testVar, 4)
expect.fullReport()
You may also review or copy the library from ./export.ahk on GitHub; #Include as you would normally when manually downloading.
Grants access to a class named expect
with the following methods: .equal
, .notEqual
, .true
, .false
, .label
, .group
, .report
, .fullReport
, and .writeResultsToFile
expect := new expect()
; .equal checks and logs whether or not both arguments are the same
expect.label("string comparison")
expect.equal("StringExample", "StringExample")
expect.label("value testing")
expect.equal((1 > 0 ), true)
expect.label("true/false testing")
expect.true((1 == 1))
expect.false((1 != 1))
expect.notEqual(true,false)
expect.report()
expect.fullReport()
expect.writeResultsToFile()
We kindly ask those interested to submit their contributions in the form of a pull request. Your efforts are sincerely appreciated. Thank you for your valuable contributions!
expect.equal([1, 2, 3], [1, 2, 3])
checks if param_actual and param_expected inputs are the same or equal. The comparison is always case-sensitive.
.test
Argument | Type | Description |
---|---|---|
param_actual | number/string/object | The actual value. |
param_expected | number/string/object | The expected value. |
param_note | string | (Optional) Additional notes for the test. |
(boolean): Returns true if the values are equal, else false.
expect.notEqual({ "a":1 }, { "a":false })
checks if actual and expected inputs are NOT the same or equal. The comparison is always case-sensitive.
Argument | Type | Description |
---|---|---|
param_actual | number/string/object | The actual value computed. |
param_expected | number/string/object | The expected value. |
param_note | string | Additional notes for the test (Optional). |
(boolean): Returns true if the values are different, else false.
expect.true((1 == 1))
checks if actual value is true.
Argument | Type | Description |
---|---|---|
param_actual | number/string | The actual value computed. |
param_note | string | Additional notes for the test (Optional). |
(boolean): Returns true if the values are different, else false.
expect.false((99 < 3))
checks if actual input is false.
Argument | Type | Description |
---|---|---|
param_actual | number/string/object | The actual value computed. |
param_note | string | Additional notes for the test (Optional). |
(boolean): returns true if the value is false, else false
expect.undefined("")
checks if actual is undefined (""
).
Argument | Type | Description |
---|---|---|
param_actual | number/string | The actual value computed. |
param_note | string | Additional notes for the test (Optional). |
(boolean): returns true if the value is ""
, else false
expect.group("Object Tests")
appends the label to a group of following tests for logs and readability
Argument | Type | Description |
---|---|---|
param_label | string | A human readable label prepend for the next test(s) in sequence |
expect.label("myInterestingLabel")
labels the following tests for logs and readability
Argument | Type | Description |
---|---|---|
param_label | string | A human readable label for the next test(s) in sequence |
expect.writeResultsToFile(".\myLogFile.tap")
Writes the report to a file and optionally opens the file.
Argument | Type | Description |
---|---|---|
param_filepath | string | The path of the file where the report will be written. If not provided, the default logResultPath will be used. |
(string): The report that was written to the file.
(Throws exception): If there is an error writing the report to the disk.
expect.report()
returns the full test results. This should be used with to integrate with Continuous Integration (CI) Systems
Does not accept any arguments.
(string): returns a string containing all the test results.
expect.fullReport()
Uses msgbox to display the results of all tests with details of any failures
Does not accept any arguments.
(string): The generated full report message.