{"id":7783,"date":"2023-05-12T10:33:43","date_gmt":"2023-05-12T09:33:43","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=7783"},"modified":"2023-05-12T10:33:44","modified_gmt":"2023-05-12T09:33:44","slug":"lua-unittesting","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/lua-unittesting\/","title":{"rendered":"Lua UnitTesting"},"content":{"rendered":"\n<p><a href=\"https:\/\/github.com\/lunarmodules\/busted\">https:\/\/github.com\/lunarmodules\/busted<\/a><\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"lua\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">describe('Busted unit testing framework', function()\n  describe('should be awesome', function()\n    it('should be easy to use', function()\n      assert.truthy('Yup.')\n    end)\n\n    it('should have lots of features', function()\n      -- deep check comparisons!\n      assert.same({ table = 'great'}, { table = 'great' })\n\n      -- or check by reference!\n      assert.is_not.equals({ table = 'great'}, { table = 'great'})\n\n      assert.falsy(nil)\n      assert.error(function() error('Wat') end)\n    end)\n\n    it('should provide some shortcuts to common functions', function()\n      assert.unique({{ thing = 1 }, { thing = 2 }, { thing = 3 }})\n    end)\n\n    it('should have mocks and spies for functional tests', function()\n      local thing = require('thing_module')\n      spy.on(thing, 'greet')\n      thing.greet('Hi!')\n\n      assert.spy(thing.greet).was.called()\n      assert.spy(thing.greet).was.called_with('Hi!')\n    end)\n  end)\nend)<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/github.com\/lunarmodules\/busted<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7783","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=7783"}],"version-history":[{"count":1,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7783\/revisions"}],"predecessor-version":[{"id":7784,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7783\/revisions\/7784"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=7783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=7783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=7783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}