AHK Unit Testing

Discuss the future of the AutoHotkey language
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

AHK Unit Testing

18 Aug 2019, 08:34

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.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AHK Unit Testing

18 Aug 2019, 13:08

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
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: AHK Unit Testing

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.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: AHK Unit Testing

19 Aug 2019, 07:09

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?
User avatar
hoppfrosch
Posts: 443
Joined: 07 Oct 2013, 04:05
Location: Rhine-Maine-Area, Hesse, Germany
Contact:

Re: AHK Unit Testing

03 Sep 2019, 23:44

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
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: AHK Unit Testing

04 Sep 2019, 03:36

8e083e7 is the version I was using last.
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: AHK Unit Testing

04 Sep 2019, 09:14

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

User avatar
hoppfrosch
Posts: 443
Joined: 07 Oct 2013, 04:05
Location: Rhine-Maine-Area, Hesse, Germany
Contact:

Re: AHK Unit Testing

04 Sep 2019, 23:16

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.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: AHK Unit Testing

05 Sep 2019, 23:58

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.

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: Leli196 and 53 guests