Unit testing framework.
UTest will scan the script for functions which name starts with “Test_”. Test functions have no parameter and use one of the Assert functions. If Assert function fails, test will fail and you will see that in the result CSV (or in ListView representing that CSV). Result shows the the test state, the function name, line number and test name if you have it.
To test your script, use the following template :
#include UTest.ahk return Test_MyTest1() { } Test_MyTest2() { } ... ... #include FunctionToTest.ahk
By default, executing the test script will show the GUI with the results. To get the same results in textual form you can set NoGui option and query Result variable from UTest storage:
UTest("NoGUI", true) #include UTest.ahk msgbox UTest("Result")
Result | Test result (OK | FAIL). |
Test | Test function name. |
Line | Line number of the test. |
Name | List of names that failed. Name is the Assert user label. Give name to the Assert function if you have multiple Assert functions inside single test. |
Param | List of parameters which failed (Assert_True, Assert_False) |
Aditionally, if you use Gui, tests that failed will be selected and if any of the test failed, complete operation will be marked as failed at the bottom of the gui.
UTest | Unit testing framework. |
Assert_True | Check if conditions are true. |
Assert_False | Check if conditions are false. |
Assert_Empty | Check if variable is empty. |
Assert_NotEmpty | Check if variable is not empty. |
Assert_Contains | Check if variable contains string. |
Assert_StartsWith | Check if variable starts with string. |
Assert_EndsWith | Check if variable ends with string. |
Assert_Match | Check if variable content matches RegEx pattern. |
UTest_Edit | Open editor with given file and go to line number. |
About |
Check if conditions are true.
Assert_True( b1 = "", b2 = "", b3 = "", b4 = "", b5 = "", b6 = "", b7 = "", b8 = "", b9 = "", b10 = "" )
Check if conditions are false.
Assert_False( b1 = "", b2 = "", b3 = "", b4 = "", b5 = "", b6 = "", b7 = "", b8 = "", b9 = "", b10 = "" )
Check if variable is empty.
Assert_Empty( Var, Name = "" )
Check if variable is not empty.
Assert_NotEmpty( Var, Name = "" )
Check if variable contains string.
Assert_Contains( Var, String, Name = "" )
Check if variable starts with string.
Assert_StartsWith( Var, String, Name = "" )
Check if variable ends with string.
Assert_EndsWith( Var, String, Name = "" )
Check if variable content matches RegEx pattern.
Assert_Match( Var, RegEx, Name = "" )
Open editor with given file and go to line number.
UTest_Edit( Path, LineNumber )