Page 1 of 1

AHK Unit Testing

Posted: 18 Aug 2019, 08:34
by kczx3
Is there any sort of unit testing done on new releases (or even for each commit)?

I was just thinking that something that might be helpful is to even just execute all examples in the docs and just check for any exceptions to be thrown.

Re: AHK Unit Testing

Posted: 18 Aug 2019, 13:08
by jeeswg
I've shared some test code, here. (At some point I plan to create a variant that doesn't need the user to monitor it.)
commands as functions (AHK v2 functions for AHK v1) - Page 2 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=29689&p=210822#p210822

Re: AHK Unit Testing

Posted: 19 Aug 2019, 04:02
by lexikos
You are welcome to create some unit tests. If they can be completely automated, I will use them.

I have unit tests for Object.ahk, which don't work anymore because they're written for a previous alpha. Yunit was a bit troublesome since Yunit uses objects, and Object.ahk changes the way they work. I adapted most of the tests while I was integrating those changes, but they required repeated modification to keep up with changes to the design.

Re: AHK Unit Testing

Posted: 19 Aug 2019, 07:09
by kczx3
I simply wasn't sure if any existed and were used. Although, I didn't look that hard for the answer before posting.

Not confident I'd be up to the task of writing them. With executing the examples in the docs, it might be difficult for any script that is persistent. I suppose you could just use a settimer to check if the process still exists after 5 or 10 seconds and if so, just kill it. Would you have to utilize dbgp to catch the exceptions/errors thrown?

Re: AHK Unit Testing

Posted: 03 Sep 2019, 23:44
by hoppfrosch
lexikos wrote:
19 Aug 2019, 04:02
You are welcome to create some unit tests. If they can be completely automated, I will use them.

I have unit tests for Object.ahk, which don't work anymore because they're written for a previous alpha. Yunit was a bit troublesome since Yunit uses objects, and Object.ahk changes the way they work. I adapted most of the tests while I was integrating those changes, but they required repeated modification to keep up with changes to the design.
@lexikos: Do you have an up-to-date version of YUnit available, which works with AHK2 a104? I would like to use it within my own projects :D

Re: AHK Unit Testing

Posted: 04 Sep 2019, 03:36
by lexikos
8e083e7 is the version I was using last.

Re: AHK Unit Testing

Posted: 04 Sep 2019, 09:14
by guest3456
lexikos wrote:
04 Sep 2019, 03:36
8e083e7 is the version I was using last.
can you create a PR to the Uberi repo?

Re: AHK Unit Testing

Posted: 04 Sep 2019, 23:16
by hoppfrosch
lexikos wrote:
04 Sep 2019, 03:36
8e083e7 is the version I was using last.
Thank you - I'll be using it .... :thumbup:
I second guest3456's request for creating a pull request.

Re: AHK Unit Testing

Posted: 05 Sep 2019, 23:58
by lexikos
The changes I made were specifically to make my own pre-a104 test script work, and were made incrementally while the language was in an (even more than usual for v2) unstable state. I will not guarantee that it will work the same way as before, or be compatible with any other Yunit-based scripts. If you have confirmed there are no problems, it should be trivial for you to merge the changes directly.