<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
The article is very good, but it does not focuse on all aspects.<br>
<br>
I have tried to create my first test example, but it didn't work.
The compilation is successful and the program is executed without
errors. However, I received no messages, informing the test has
failed. Actually, the test should be failed.<br>
<br>
This example is seemingly equivalent the minimum example supplied
by the article.<br>
<br>
As recommended, I only add the unit "test" in the clause "uses", so
the test was expected to run. Does someone know what is wrong?<br>
<br>
First of all, a unit with a routine to be tested:<br>
<br>
unit numbers;<br>
{$mode objfpc}{$h+}<br>
<br>
interface<br>
uses<br>
Sysutils;<br>
<br>
function calculate(a, b: integer):integer;<br>
implementation<br>
<br>
function calculate(a, b: integer):integer;<br>
begin<br>
result := a + b;<br>
end;<br>
<br>
INITIALIZATION<br>
END.<br>
<br>
Now, my testcase class:<br>
<br>
unit test;<br>
{$mode objfpc}{$h+}<br>
<br>
interface<br>
numbers, fpcunit, testregistry;<br>
uses<br>
<br>
type<br>
TBugTest = class(TTestCase)<br>
published<br>
procedure calculate;<br>
end;<br>
<br>
implementation<br>
procedure TBugTest.calculate;<br>
begin<br>
AssertEquals('The calculation is not done', 8, numbers.calculate(5,
4));<br>
end;<br>
<br>
INITIALIZATION<br>
RegisterTest(TBugTest);<br>
END.<br>
<br>
Now, the runer:<br>
<br>
program apptest;<br>
{$mode objfpc}{$h+}<br>
<br>
uses<br>
test;<br>
<br>
begin<br>
end.<br>
<br>
Em 16/12/2011 11:44, Michael Van Canneyt escreveu:
<blockquote
cite="mid:alpine.DEB.2.00.1112161444090.7268@home.telenet.be"
type="cite">
<br>
<br>
On Fri, 16 Dec 2011, Vincent Snijders wrote:
<br>
<br>
<blockquote type="cite">2011/12/16 luciano de souza
<a class="moz-txt-link-rfc2396E" href="mailto:luchyanus@gmail.com"><luchyanus@gmail.com></a>:
<br>
<blockquote type="cite">Hello listers,
<br>
<br>
Navigating in FPC source codes, I found fpcunit. It's really
<br>
wonderful. With the tTestCase class, we can generate a report
with
<br>
the success or the failure of our tests.
<br>
<br>
Is there documentation on the usage of fpcunit? What is the
best way
<br>
to study it?
<br>
</blockquote>
<br>
Google found this (old) article:
<br>
<a class="moz-txt-link-freetext" href="http://www.freepascal.org/olddocs-html/fpcunit.pdf">http://www.freepascal.org/olddocs-html/fpcunit.pdf</a>
<br>
</blockquote>
<br>
It is old, but still correct.
<br>
<br>
I will see about refreshing it, and adding it in the FPC
documentation.
<br>
<br>
Michael.<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
fpc-pascal maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a></pre>
</blockquote>
<br>
<br>
<div class="moz-signature">-- <br>
Luciano de Souza</div>
</body>
</html>