diff --git a/spec/example_spec.lua b/spec/example_spec.lua index ab4bd4d..379f2b5 100644 --- a/spec/example_spec.lua +++ b/spec/example_spec.lua @@ -24,5 +24,48 @@ describe("Busted unit testing framework", function() it("should provide some shortcuts to common functions", function() assert.are.unique({{ thing = 1 }, { thing = 2 }, { thing = 3 }}) end) + + it("should present failed assertions with FAILED", function() + assert.falsy(0) + end) + + it("should present failed assertions with custom message", function() + assert.are.same(13, 42, "Incorrect answer for input n=10") + end) + + describe("should present errors in IT with LOG", function() + it("IT with an error", function() + local nilobj = nil + nilobj.test() + assert.falsy(0) + end) + end) + + describe("should present errors in describe with ERROR", function() + + local nilobj = nil + nilobj.test() + + it("dummy IT", function() + assert.falsy(0) + end) + end) + + describe("should present errors in IT titles with ERROR", function() + local nilobj = nil + it("it block with ERROR" .. nilobj.test(), function() + assert.falsy(0) + end) + end) + end) + + describe("Should support newlines\nin group titles", function() + it("Should support newlines\nin test titles", function() + assert.truthy(0, "Should support newlines\nin assertion messages") + end) + it("Should support newlines\nin errors", function() + error("Error message with...\n a newline") + assert.truthy(0) + end) end) end) diff --git a/src/busted/outputHandlers/codewars.lua b/src/busted/outputHandlers/codewars.lua index 33e58fe..4f7a83c 100644 --- a/src/busted/outputHandlers/codewars.lua +++ b/src/busted/outputHandlers/codewars.lua @@ -6,7 +6,7 @@ return function(options) end local function onDescribeStart(element, parent) - print('\n' .. element.name) + print('\n' .. escape(element.name)) return nil, true end local function onDescribeEnd(element, parent) @@ -16,7 +16,7 @@ return function(options) end local function onTestStart(element, parent) - print('\n' .. element.name) + print('\n' .. escape(element.name)) return nil, true end local function onTestEnd(element, parent, status, trace) @@ -29,9 +29,9 @@ return function(options) end local function onTestFailure(element, parent, message, debug) - print('\nTest Failed') -- remove '/home/codewarrior/lua/fixture.lua:\d+: ' from message - print('\n' .. escape(message:sub(message:find(' ') + 1))) + local msg = escape(message:sub(message:find(' ') + 1)) + print('\n' .. msg) return nil, true end @@ -43,8 +43,7 @@ return function(options) local function onError(element, parent, message, debug) if element.descriptor ~= 'it' then - print('\nError') - print('\n' .. escape(message)) + print('\nError<:LF:>' .. escape(message)) end return nil, true end