(580 Kb)
Updated: 05-31-18 03:34 AM
File Info
Shadows of Argus (7.3.0)
Updated:05-31-18 03:34 AM
Created:05-27-18 07:29 AM
Categories:Developer Utilities, Libraries


Version: 1.1.0
by: wartoshika [More]


Lua as an interpreter language without and support for good code intelligence and suggestion is a difficult to write language. With the technically old World of Warcraft addon API the task is even harder.

In the past i have written many addons and any change to some feature resulted in a may work or may not work situation. I have to test everything myself and this is time and happyness consuming . Without further ado i present you an object oriented unit test framework for World of Warcraft addons.

I adopted the common unit test design patterns and names from other languages like php, java and typescript to allow easy step in into unit testing with World of Warcraft and Lua.

Happy testing!

Please also visit the Github page for issues, contribution and documentation! Github [wartoshika/wow-QhunUnitTest]


The following main features were supported:
- Testsuites
- A bunch of assert functions
- Setup and teardown on class and method level
- Easy to understand result print
- Ingame command line interface
- Count of tests, errors and asserts
- Powerfull abstract test class for your component
- Wrapping / Mocking existing objects to test for method calls (even with exact arguments)
- An Error per test system (All tests will run, even if one failed)


If you want to contribute to this addon, please develop your features/bug fixes on a fork of this project. You can then make a pull request and we can discuss the changes within a separate ticket.


This is a simple test class.

Lua Code:
  1. if not IsAddOnLoaded("QhunUnitTest") then
  2.     return
  3. end
  5. QhunCore.Test.Storage = {}
  6. QhunCore.Test.Storage.__index = QhunCore.Test.Storage
  8. -- constructor
  9. function QhunCore.Test.Storage.new()
  11.     -- call super class
  12.     local instance = QhunUnitTest.Base.new()
  14.     -- bind current values
  15.     setmetatable(instance, QhunCore.Test.Storage)
  17.     return instance
  18. end
  20. -- set inheritance
  21. setmetatable(QhunCore.Test.Storage, {__index = QhunUnitTest.Base})
  23. --[[
  24.     TESTS
  25. ]]
  26. -- the name of the method will be visible in the test report
  27. function QhunCore.Test.Storage:canBeInstantiated()
  29.     -- create a storage instance
  30.     local instance = QhunCore.Storage.new()
  32.     -- test if the returned instance is a class of type QhunCore.Storage
  33.     self:assertClassOf(instance, QhunCore.Storage)
  34. end

The test class should be registered in your test suite. This is a testsuite example:

Lua Code:
  1. -- check if the unit test addon is available
  2. if IsAddOnLoaded("QhunUnitTest") then
  4.     -- create a test suite
  5.     local suite = QhunUnitTest.Suite.new("QhunCore")
  7.     -- register the defined test class
  8.     suite:registerClass("Storage", QhunCore.Test.Storage.new())
  10.     -- register for slash
  11.     suite:registerForSlashCommand()
  12. end

You now can access the ingame command line api to show the result of the test. The command looks like
/test QhunCore
. You will see a result in the attached pictures.


I have added a documentation.md file into the repository. View my Github page for the current documentation.

You can now review a mostly complete documentation on the Github page above.

I will add the documentation.md file into the ZIP-File when completed. Until then view the Github page.


MIT style licence, see licence file for more details

# QhunUnitTest - Changelog

I use Semantic Versioning for version numbers (MAJOR, MINOR, PATCH).

TL; DR: PATCH and MINOR changes are allways compatible. MAJOR releases can beak the existing API!

Every PATCH version contains Bugfixes or general stuff like refactoring or comment changes. Every MINOR version contains features that are always backwards compatible. Every MAJOR version contains API changes, features that are not backwards compatible.

## 1.1.0
- [Feature] [code single]QhunUnitTest.Base.new()[/code] has a new constructor parameter for specifying the order of test methods.

## 1.0.1
- [Bugfix] [code single]assertTableSimilar[/code] does not increase the assert count.
- [Bugfix] [code single]QhunUnitTest.Base:assertError[/code] throws error if no arguments given.
- [Bugfix] [code single]QhunUnitTest.Wrapper:__index[/code] throw error when calling [code single]__unittest_getMethodCallAmount[/code] without existing calls stored in [code single]_calledFunctions[/code]
- [General] Added tests for [code single]base.lua[/code], [code single]suite.lua[/code] and [code single]wrapper.lua[/code]

## 1.0.0 Release
- Lots of features added to the first public release!
Archived Files (1)
File Name
05-27-18 07:29 AM

There have been no comments posted to this file.
Be the first to add one.

Category Jump:

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.