Page 1 of 1

UnitTesting for Lua Scripts written against Command

Posted: Fri May 29, 2020 12:12 pm
by jkgarner
OK, I am a developer/software engineer by trade. When I write professionally, I am interested in making sure that my code is correct and runs error-free. To this end, I employ unit testing, and regression testing and do so automatically, every time I submit changes. This ensures that the codebase remains error-free, or at least if I interject bugs, they are detected right away.

This said, as I write scripts against the Command's Lua objects for running in my scenarios, I am VERY interested in unit testing my functions to prove they are correct before tying them to my scenarios. To this end, I have several questions:

1. Is there a UnitTest library/Framework that is in use by the community that works well against Command's Lua API?
2. Is it employed to allow automated testing of code?
3. How is #2 accomplished/setup?

I would love a discussion on various tools, and the merits and methods used to employ them.


RE: UnitTesting for Lua Scripts written against Command

Posted: Fri May 29, 2020 7:28 pm
by KnightHawk75
[:D] Interesting topic. Sounds like a good topic\question for the next Command Pro twitch live stream, I've always wondered how organizational customers manage all their cmo\cmano script libraries and testing, though I imagine Pro opens up some features that make life easier on that front it should make for interesting reading\listening.

RE: UnitTesting for Lua Scripts written against Command

Posted: Sun May 31, 2020 8:58 pm
by kevinkins
http://lua-users.org/wiki/UnitTesting

Probably not what the OP had in mind since the page is not specific to Command's Lua API. But the link might spark some ideas. I have a feeling that functions used professionally will require a more specific testing environment with more detailed outputs. But for everyone else writing advanced scripts that are used across a bunch of scenarios to be enjoyed by players, maybe the link provides some tools.

Kevin

RE: UnitTesting for Lua Scripts written against Command

Posted: Sun May 31, 2020 9:36 pm
by jkgarner
@kevinkins: I went out to that page and looked over what was available there ( http://lua-users.org/wiki/UnitTesting ), and did some additional searching.

The result of my searches and a few days work is a library of Lua files, that link together into a cohesive library and a unit-test mechanism (borrowed from https://github.com/catwell/cwtest) that can be tied into the system and execute individual tests against individual functions.

I am uploading the initial library (called AFWI) to this post for you all to examine.

This is an initial stab at solving the problem of unit testing within the environment and organizing the individual Lua scripts.

I would like a discussion of the merits (and potential problems) of what I put together, or better yet, other proposed solutions to examine.