Adding example of XML loading test
This commit is contained in:
14
.github/workflows/test.yml
vendored
14
.github/workflows/test.yml
vendored
@@ -12,11 +12,17 @@ jobs:
|
||||
luaVersion: "luajit-2.0.5"
|
||||
- name: Install LuaRocks
|
||||
uses: leafo/gh-actions-luarocks@v4.0.0
|
||||
- name: Install luaunit
|
||||
run: luarocks install luaunit
|
||||
- name: Install busted
|
||||
run: luarocks install busted
|
||||
- name: Install cluacov
|
||||
run: luarocks install cluacov
|
||||
- name: Install coveralls integration
|
||||
run: luarocks install luacov-coveralls
|
||||
- name: Unzip for lua libs
|
||||
run: unzip runtime-win32.zip
|
||||
- name: Copy Lua libs
|
||||
- name: Set LUA_PATH
|
||||
run: cp lua/*.lua ./
|
||||
- name: Run tests
|
||||
run: luajit Test/TestRunner.lua
|
||||
run: busted -c Test/TestRunner.lua
|
||||
- name: Report coverage
|
||||
run: luacov-coveralls
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
TestAttack = {}
|
||||
|
||||
function TestAttack:setUp()
|
||||
newBuild()
|
||||
end
|
||||
|
||||
function TestAttack:testCritChance()
|
||||
lu.assertEquals(build.calcsTab.mainOutput.CritChance, 0)
|
||||
build.itemsTab:CreateDisplayItemFromRaw("New Item\nMaraketh Bow\nCrafted: true\nPrefix: None\nPrefix: None\nPrefix: None\nSuffix: None\nSuffix: None\nSuffix: None\nQuality: 20\nSockets: G-G-G-G-G-G\nLevelReq: 71\nImplicits: 1\n{tags:speed}10% increased Movement Speed")
|
||||
build.itemsTab:AddDisplayItem()
|
||||
runCallback("OnFrame")
|
||||
lu.assertEquals(build.calcsTab.mainOutput.CritChance, 5.5 * build.calcsTab.mainOutput.HitChance / 100)
|
||||
end
|
||||
|
||||
function TestAttack:testCritMulti()
|
||||
lu.assertEquals(build.calcsTab.mainOutput.CritChance, 0)
|
||||
build.itemsTab:CreateDisplayItemFromRaw("New Item\nAssassin Bow\nCrafted: true\nPrefix: None\nPrefix: None\nPrefix: None\nSuffix: None\nSuffix: None\nSuffix: None\nQuality: 20\nSockets: G-G-G-G-G-G\nLevelReq: 62\nImplicits: 1\n{tags:damage,critical}{range:0.5}+(15-25)% to Global Critical Strike Multiplier")
|
||||
build.itemsTab:AddDisplayItem()
|
||||
runCallback("OnFrame")
|
||||
lu.assertEquals(build.calcsTab.mainOutput.CritMultiplier, 1.5 + .2)
|
||||
end
|
||||
|
||||
function TestAttack:tearDown()
|
||||
-- newBuild() takes care of resetting everything in setUp()
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
TestBuilds = {}
|
||||
|
||||
function TestBuilds:testBuilds()
|
||||
local testBuild = LoadModule("Test/TestBuilds/3.13/OccVortex")
|
||||
loadBuildFromXML(testBuild.xml)
|
||||
for key, value in pairs(testBuild.output) do
|
||||
lu.assertEquals(build.calcsTab.mainOutput[key], value)
|
||||
end
|
||||
end
|
||||
25
Test/System/TestAttacks.lua
Normal file
25
Test/System/TestAttacks.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
describe("TestAttacks", function()
|
||||
before_each(function()
|
||||
newBuild()
|
||||
end)
|
||||
|
||||
teardown(function()
|
||||
-- newBuild() takes care of resetting everything in setup()
|
||||
end)
|
||||
|
||||
it("creates an item and has the correct crit chance", function()
|
||||
assert.same(build.calcsTab.mainOutput.CritChance, 0)
|
||||
build.itemsTab:CreateDisplayItemFromRaw("New Item\nMaraketh Bow\nCrafted: true\nPrefix: None\nPrefix: None\nPrefix: None\nSuffix: None\nSuffix: None\nSuffix: None\nQuality: 20\nSockets: G-G-G-G-G-G\nLevelReq: 71\nImplicits: 1\n{tags:speed}10% increased Movement Speed")
|
||||
build.itemsTab:AddDisplayItem()
|
||||
runCallback("OnFrame")
|
||||
assert.same(build.calcsTab.mainOutput.CritChance, 5.5 * build.calcsTab.mainOutput.HitChance / 100)
|
||||
end)
|
||||
|
||||
it("creates an item and has the correct crit multi", function()
|
||||
assert.same(1.5, build.calcsTab.mainOutput.CritMultiplier)
|
||||
build.itemsTab:CreateDisplayItemFromRaw("New Item\nAssassin Bow\nCrafted: true\nPrefix: None\nPrefix: None\nPrefix: None\nSuffix: None\nSuffix: None\nSuffix: None\nQuality: 20\nSockets: G-G-G-G-G-G\nLevelReq: 62\nImplicits: 1\n{tags:damage,critical}{range:0.5}+(15-25)% to Global Critical Strike Multiplier")
|
||||
build.itemsTab:AddDisplayItem()
|
||||
runCallback("OnFrame")
|
||||
assert.same(1.5 + .2, build.calcsTab.mainOutput.CritMultiplier)
|
||||
end)
|
||||
end)
|
||||
28
Test/System/TestBuilds.lua
Normal file
28
Test/System/TestBuilds.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
function TestBuilds:fetchBuilds(path, buildList)
|
||||
local buildList = buildList or {}
|
||||
for file in lfs.dir(path) do
|
||||
if file ~= "." and file ~= ".." then
|
||||
local f = path..'/'..file
|
||||
local attr = lfs.attributes (f)
|
||||
assert (type(attr) == "table")
|
||||
if attr.mode == "directory" then
|
||||
TestBuilds:fetchBuilds(f, buildList)
|
||||
else
|
||||
table.insert(buildList, LoadModule(f))
|
||||
end
|
||||
end
|
||||
end
|
||||
return buildList
|
||||
end
|
||||
|
||||
describe("test all test builds", function()
|
||||
it("finds all test builds and compares their output", function()
|
||||
local buildList = TestBuilds:fetchBuilds("Test/TestBuilds")
|
||||
for _, testBuild in ipairs(buildList) do
|
||||
loadBuildFromXML(testBuild.xml)
|
||||
for key, value in pairs(testBuild.output) do
|
||||
assert.same(build.calcsTab.mainOutput[key], value)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
@@ -1,7 +1,11 @@
|
||||
require("HeadlessWrapper")
|
||||
lu = require('luaunit')
|
||||
lfs = require("lfs")
|
||||
require 'busted.runner'()
|
||||
describe("some", function()
|
||||
it("does something", function()
|
||||
assert.same(1,1)
|
||||
end)
|
||||
end)
|
||||
|
||||
LoadModule("Test/Scenario/TestAttacks")
|
||||
LoadModule("Test/Scenario/TestBuilds")
|
||||
|
||||
os.exit( lu.LuaUnit.run() )
|
||||
LoadModule("Test/System/TestAttacks")
|
||||
LoadModule("Test/System/TestBuilds")
|
||||
Reference in New Issue
Block a user