You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sinaloit edited this page Jun 21, 2014
·
1 revision
To use LibBusted you will need to do three things:
Create your unit tests. Documentation on Busted in general can be found here
Edit your toc.xml to include references to your new unit tests.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<AddonAuthor="YourName"APIVersion="8"Name="MyAddon"Description="Does Stuff"Version="SomeVersion">
<!-- Whatever Packages you have -->
<ScriptName="libs\LibAssert-1.0\LibAssert-1.0.lua"/>
<ScriptName="libs\LibBusted-2.0\LibBusted-2.0.lua"/>
<!-- Whatever Scripts you have -->
<ScriptName="MyAddon.lua"/>
<FormName="MyAddon.xml"/>
<!-- Whatever Tests you have -->
<TestName="SomeTest"File="tests\SomeTest_spec.lua"/>
<TestName="SomeOtherTest"File="tests\SomeOtherTest_spec.lua"/>
</Addon>
Register your addon with LibBusted in your OnLoad
Example:
functionMyAddon:OnLoad()
Apollo.GetPackage("Lib:Busted-2.0").tPackage:Register(self)
-- Whatever other things you do in OnLoadend
You can now run a test whenever you would like.
Example:
-- Runs the specified testMyAddon:RunTest("SomeTest")
-- Runs all tests registeredMyAddon:RunTests()
-- Alternatively you can iterate through the tests if you'd likeforstrTestName, strTestFilenameinMyAddon:IterateTests() do-- Something with the testend