[Lazarus] Bored?

Graeme Geldenhuys graeme at geldenhuys.co.uk
Tue Apr 16 10:29:54 CEST 2013


On 16/04/13 08:14, Michael Van Canneyt wrote:
>> .... lack of warnings about
>> tests that don't actually call any AssertXXX() methods,
> 
> I have lots of such methods ?
>    if xyz then
>      fail()


Uh... here is an example of what I am talking about.


---------------------
unit TestCase1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, fpcunit, testutils, testregistry;

type

  TTestCase1 = class(TTestCase)
  published
    procedure SilentFailure;
  end;

implementation

procedure TTestCase1.SilentFailure;
var
  i: integer;
begin
  i := 10;
  // Test doesn't actually call AssertXXX() or CheckXXX(), yet FPCUnit
thinks it passed
end;



initialization

  RegisterTest(TTestCase1);
end.
--------------------------


And here is the FPCUnit results..

graemeg at ubuntu:/tmp$ ./fpcunitproject1 -a --format=plain
 Time:00.000 N:1 E:0 F:0 I:0
  TTestCase1 Time:00.000 N:1 E:0 F:0 I:0
    00.000  SilentFailure

Number of run tests: 1
Number of errors:    0
Number of failures:  0



Yes a simple example, but this issue is very possible in complex tests,
or if the developer got sidetracked. And note, FPCUnit reported no
problems or warnings at all.



And here is the FPTest results:


graemeg at ubuntu:/tmp$ ./project2

FPTest / Testing
.W
Time: 00:00:00.000


OK: 1 tests
There was 1 warning:

  1) project2.TMyTestCase.SilentFailure: EPostTestWarning
     at $00000000004001A0
No checks executed in TestCase





Regards,
  - Graeme -





More information about the Lazarus mailing list