Testing, collecting and printing of custom error messages

K

Kga Agk

I want to i want to store the messages n the assertions and print them
in a cleen output. I am going to test a bunch of testes and i want to
give a aoutput that puts the name of the test and success if it succeds,
and if it has errors then it print name, error and a cleean short
description of the errors.


I youse Rspec, and i have initielized shoulda to.

escribe "Echo" do
include ... some stuff

before :all do
...
some startup stuff
...
end
after:)all) do
... #print collected errors, or othe reports
end

it "Err" do
assert(false, "I want to store this error message")
end
end


I have tried to use a seperate class ad written the assert like this.

assert(false, errorReport.push("I want to store this error message"))

But by doing that the message is printed bouth when the test fails and
when it succeds, and i want it only if it fails.
 
K

Kga Agk

Is there somthing like. If assertion is false, then do somthing. Becouse
i want to store my own easy error messages in adition to those the test
framework prints out. I can do this by writing som extra code, or my own
assertion methods, but i thought it might be a easye way, just by using
those asertions that already are there.

Somthing like this should hav worked.

if assert(false) == false then
report.pushError("It was false")
end

or if i wrote this

assert false, report.pushError("It was false")

then the secound parameter would only be don when the assertion was
false, and not when it is true also, as it dos now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top