Basic ZScript unit test framework for GZDoom
Inspired by Lilac by Chesko
class ClematisExample : Clematis {
override
void TestSuites() {
//////////////////
// Assert-style //
//////////////////
Describe('Testing Player Stats');
It('MaxHealth', AssertEval(20, '<', 100), LOG_Warning);
It('Math', AssertEval(1+1, '==', 2), LOG_Fatal);
It('Woot', Assert(true), LOG_Fatal);
EndDescribe();
let x = new('Object');
let y = new('Object');
Describe('Testing Math');
It('Calculus', AssertFalse(0*1!=0), LOG_Error);
It('Math', AssertSame(x, y, "Custom error message using values (%p and %p)"), LOG_Warning);
EndDescribe();
//////////////////
// Expect-style //
//////////////////
Describe('Testing 123');
It('Lorum', ExpectNum(12).to.be.lessThan().thisNum(30), LOG_Error);
It('Ipsum', ExpectObj(new('Object')).to.be.instance().of.thisCls('Object'), LOG_Error);
It('Call explicit matchers which can be added', ExpectNum(0, 'not >=').thisNum(42), LOG_Info);
EndDescribe();
}
}
Override TestSuites and put in your own!
Suites are started with Describe
and end with EndDescribe
Tests run on instantiation by default, which can be disabled by overriding Init()
Clematis.Create('ClematisExample');
EventHandler.SendNetworkEvent('test:ClematisExample');
netevent test:ClematisExample
Clematis Tester=Clematis.Create('ClematisExample');
Tester.Run();
Clematis is under the BSD 3-Clause License