Coder Social home page Coder Social logo

expect.ahk's Introduction



A Test Anything Protocol (TAP) compliant unit testing package for AutoHotkey

Installation

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.

Usage

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()

Contributing

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!

API

.equal

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.

Aliases

.test

Arguments

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.

Returns

(boolean): Returns true if the values are equal, else false.

.notEqual

expect.notEqual({ "a":1 }, { "a":false })

checks if actual and expected inputs are NOT the same or equal. The comparison is always case-sensitive.

Arguments

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).

Returns

(boolean): Returns true if the values are different, else false.

.true

expect.true((1 == 1))

checks if actual value is true.

Arguments

Argument Type Description
param_actual number/string The actual value computed.
param_note string Additional notes for the test (Optional).

Returns

(boolean): Returns true if the values are different, else false.

.false

expect.false((99 < 3))

checks if actual input is false.

Arguments

Argument Type Description
param_actual number/string/object The actual value computed.
param_note string Additional notes for the test (Optional).

Returns

(boolean): returns true if the value is false, else false

.undefined

expect.undefined("")

checks if actual is undefined ("").

Arguments

Argument Type Description
param_actual number/string The actual value computed.
param_note string Additional notes for the test (Optional).

Returns

(boolean): returns true if the value is "", else false

.group

expect.group("Object Tests")

appends the label to a group of following tests for logs and readability

Arguments

Argument Type Description
param_label string A human readable label prepend for the next test(s) in sequence

.label

expect.label("myInterestingLabel")

labels the following tests for logs and readability

Arguments

Argument Type Description
param_label string A human readable label for the next test(s) in sequence

.writeResultsToFile

expect.writeResultsToFile(".\myLogFile.tap")

Writes the report to a file and optionally opens the file.

Arguments

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.

Returns

(string): The report that was written to the file.

Exceptions

(Throws exception): If there is an error writing the report to the disk.

.report

expect.report()

returns the full test results. This should be used with to integrate with Continuous Integration (CI) Systems

Arguments

Does not accept any arguments.

Returns

(string): returns a string containing all the test results.

.fullReport

expect.fullReport()

Uses msgbox to display the results of all tests with details of any failures

Arguments

Does not accept any arguments.

Returns

(string): The generated full report message.

expect.ahk's People

Contributors

chunjee avatar

Stargazers

Mark Wiemer avatar  avatar  avatar  avatar Joe DF avatar Joshua Clanton avatar Vladimirs Nordholm avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

jeniex

expect.ahk's Issues

FileDelete On writeResultsToFile

I was wondering if it would append to conout and passed and passed the *, as per AHK documentation, and it erased my project.

I think this should be an opt in and not a default behavior.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.