Quantcast
Download
(580 Kb)
Download
Updated: 05-31-18 03:34 AM
Pictures
File Info
Compatibility:
Shadows of Argus (7.3.0)
Updated:05-31-18 03:34 AM
Created:05-27-18 07:29 AM
Downloads:71
Favorites:1
MD5:
Categories:Developer Utilities, Libraries

QhunUnitTest

Version: 1.1.0
by: wartoshika [More]

QhunUnitTest

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]

Support

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)

Contribution

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.

Example

This is a simple test class.

Lua Code:
  1. if not IsAddOnLoaded("QhunUnitTest") then
  2.     return
  3. end
  4.  
  5. QhunCore.Test.Storage = {}
  6. QhunCore.Test.Storage.__index = QhunCore.Test.Storage
  7.  
  8. -- constructor
  9. function QhunCore.Test.Storage.new()
  10.  
  11.     -- call super class
  12.     local instance = QhunUnitTest.Base.new()
  13.  
  14.     -- bind current values
  15.     setmetatable(instance, QhunCore.Test.Storage)
  16.  
  17.     return instance
  18. end
  19.  
  20. -- set inheritance
  21. setmetatable(QhunCore.Test.Storage, {__index = QhunUnitTest.Base})
  22.  
  23. --[[
  24.     TESTS
  25. ]]
  26. -- the name of the method will be visible in the test report
  27. function QhunCore.Test.Storage:canBeInstantiated()
  28.  
  29.     -- create a storage instance
  30.     local instance = QhunCore.Storage.new()
  31.  
  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
  3.  
  4.     -- create a test suite
  5.     local suite = QhunUnitTest.Suite.new("QhunCore")
  6.  
  7.     -- register the defined test class
  8.     suite:registerClass("Storage", QhunCore.Test.Storage.new())
  9.  
  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
Code:
/test QhunCore
. You will see a result in the attached pictures.

API

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.

Licence

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
Version
Size
Author
Date
1.0
533kB
wartoshika
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.