I'm a TDD guy.
I'd like to write tests-first. Is that possible?
I mean, I can write a simple framework myself, but maybe there is something?
Manfred
How can I unit-test my code?
-
- Posts: 475
- Joined: Fri May 15, 2015 5:15 pm
- Location: Waterville, Minnesota USA
Re: How can I unit-test my code?
There is an Assert() command built in in Hollywood for that purpose.
I'm on registered MorphOS using FlowStudio.
Re: How can I unit-test my code?
OK, so I create a separate script where I import my production code and use Assert().
Does 'luaunit' actually work? How far is Hollywood away from pure lua?
Manfred
Does 'luaunit' actually work? How far is Hollywood away from pure lua?
Manfred
Re: How can I unit-test my code?
OK, I'm surprised. It works pretty well.
Very fast feedback loop. No big fuzz.
Using Classes as outlined in https://www.lua.org/pil/16.1.html. Works nicely.
Very fast feedback loop. No big fuzz.
Using Classes as outlined in https://www.lua.org/pil/16.1.html. Works nicely.
Re: How can I unit-test my code?
Andreas can answer better, but to my understanding Hollywood is basically a heavily patched LUA. That there is great difference between them, but the very core is mostly same.
-
- Posts: 475
- Joined: Fri May 15, 2015 5:15 pm
- Location: Waterville, Minnesota USA
Re: How can I unit-test my code?
Great! I started writing a framework for Hollywood once but ran into a roadblock with the include directory name being passed in as a constant and haven't gotten back to it for a while. All I currently have is an enumeration class and a unit test.asrael wrote: ↑Sat Aug 11, 2018 9:27 pm OK, I'm surprised. It works pretty well.
Very fast feedback loop. No big fuzz.
Using Classes as outlined in https://www.lua.org/pil/16.1.html. Works nicely.
Hollywood is based on Lua 5.0.2, I think. The syntax is mostly different to make it readable to beginners.
I'm on registered MorphOS using FlowStudio.
Re: How can I unit-test my code?
I think creating a simple TestCase base class that you can inherit from.
Under the convention to have test methods start with "test" and have "setUp" and "tearDown" methods defined, it should be simple to use 'reflection' retrieving all those methods and execute them.
That would make things a little simpler, because now I have to setup the 'class-under-test' in each test method, and have to execute each test method manually and the end of the script.
Under the convention to have test methods start with "test" and have "setUp" and "tearDown" methods defined, it should be simple to use 'reflection' retrieving all those methods and execute them.
That would make things a little simpler, because now I have to setup the 'class-under-test' in each test method, and have to execute each test method manually and the end of the script.
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: How can I unit-test my code?
For unit tests, the new @IF preprocessor command can also come in handy.