Skip to content
Sinaloit edited this page Jun 21, 2014 · 1 revision

To use LibBusted you will need to do three things:

  1. Create your unit tests. Documentation on Busted in general can be found here
  2. Edit your toc.xml to include references to your new unit tests.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<Addon Author="YourName" APIVersion="8" Name="MyAddon" Description="Does Stuff" Version="SomeVersion">
    <!-- Whatever Packages you have -->
    <Script Name="libs\LibAssert-1.0\LibAssert-1.0.lua"/>
    <Script Name="libs\LibBusted-2.0\LibBusted-2.0.lua"/>

    <!-- Whatever Scripts you have -->
    <Script Name="MyAddon.lua"/>
    <Form Name="MyAddon.xml"/>

    <!-- Whatever Tests you have -->   
    <Test Name="SomeTest" File="tests\SomeTest_spec.lua"/>
    <Test Name="SomeOtherTest" File="tests\SomeOtherTest_spec.lua"/>
</Addon>
  1. Register your addon with LibBusted in your OnLoad

Example:

function MyAddon:OnLoad()
    Apollo.GetPackage("Lib:Busted-2.0").tPackage:Register(self)
    --  Whatever other things you do in OnLoad
end
  1. You can now run a test whenever you would like.

Example:

    -- Runs the specified test
    MyAddon:RunTest("SomeTest")

    -- Runs all tests registered
    MyAddon:RunTests()

    -- Alternatively you can iterate through the tests if you'd like
    for strTestName, strTestFilename in MyAddon:IterateTests() do
        -- Something with the test
    end

Clone this wiki locally