UnitTesting for Lua Scripts written against Command

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
jkgarner
Posts: 175
Joined: Thu Apr 30, 2020 12:42 pm

UnitTesting for Lua Scripts written against Command

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

KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: UnitTesting for Lua Scripts written against Command

Post 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.
User avatar
kevinkins
Posts: 2465
Joined: Wed Mar 08, 2006 11:54 am

RE: UnitTesting for Lua Scripts written against Command

Post 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
“The study of history lies at the foundation of all sound military conclusions and practice.”
Alfred Thayer Mahan
jkgarner
Posts: 175
Joined: Thu Apr 30, 2020 12:42 pm

RE: UnitTesting for Lua Scripts written against Command

Post 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.
Attachments
AFWI_Lua_lib.zip
(27.93 KiB) Downloaded 24 times
Post Reply

Return to “Lua Legion”