unit-testing - Delphi XE2 中的重复构造函数警告

标签 unit-testing delphi

我有以下 .dpr

program TPWDDBManager;
{

  Delphi DUnit Test Project
  -------------------------
  This project contains the DUnit test framework and the GUI/Console test runners.
  Add "CONSOLE_TESTRUNNER" to the conditional defines entry in the project options
  to use the console test runner.  Otherwise the GUI test runner will be used by
  default.

}

{$IFDEF CONSOLE_TESTRUNNER}
{$APPTYPE CONSOLE}
{$ENDIF}

uses
  DUnitTestRunner,
  TestuTPWDDBManager in 'TestuTPWDDBManager.pas';

{$R *.RES}

begin
  DUnitTestRunner.RunRegisteredTests;
end.

以及以下单位:

unit TestuTPWDDBManager;
{

  Delphi DUnit Test Case
  ----------------------
  This unit contains a skeleton test case class generated by the Test Case Wizard.
  Modify the generated code to correctly setup and call the methods from the unit
  being tested.

}

interface

uses TestFramework;

type
  // Test methods for class TPWDDBManager

  TestTPWDDBManager = class(TTestCase)
  strict private
  public
    procedure SetUp; override;
    procedure TearDown; override;
  published
    procedure TestUpdateVersion;
    procedure TestGetPWD;
    procedure TestChangePWD;
    procedure TestReset;
    procedure TestIsReset;

  end;

  Idlg = interface(IInvokable)
    ['{E369D075-E3CA-4BB3-896C-0D623DE5798F}']

  end;

implementation

uses SysUtils,Delphi.Mocks;

procedure TestTPWDDBManager.SetUp;
var
  FMessageDLG : TMock<IDlg>;
begin
end;

procedure TestTPWDDBManager.TearDown;
begin
end;

procedure TestTPWDDBManager.TestGetPWD;
begin
  // TODO: Validate method results
end;

procedure TestTPWDDBManager.TestIsReset;
begin
end;

procedure TestTPWDDBManager.TestChangePWD;
begin
end;

procedure TestTPWDDBManager.TestReset;
begin
end;

procedure TestTPWDDBManager.TestUpdateVersion;
begin

end;

initialization
  // Register any test cases with the test runner
  RegisterTest(TestTPWDDBManager.Suite);
end.

当我编译时,我收到几个警告,例如:

[DCC Warning] W1029 Duplicate constructor 'TExpectation.CreateAfter' with identical parameters will be inacessible from C++ [DCC Warning] W1029 Duplicate constructor 'TExpectation.CreateAfterWhen' with identical parameters will be inacessible from C++ [DCC Warning] W1029 Duplicate constructor 'TExpectation.CreateAtLeastOnce' with identical parameters will be inacessible from C++

但是如果我删除行 FMessageDLG : TMock<IDlg>;然后警告消失

知道如何解决这个问题吗?

最佳答案

delphi 项目中的 Delphi Mocks 和 C++ 兼容性编译器标志相互不兼容。只需关闭编译器设置中的 C++ 兼容性选项即可。请记住,Delphi 有多种用途。此警告在某些使用场景中有用,但在大多数 delphi 用户的日常工作中却不起作用。您可以禁用该警告。

{$WARN DUPLICATE_CTOR_DTOR OFF} 

根据修复需要添加到您的项目 (.dpr) 范围或单元范围。

关于unit-testing - Delphi XE2 中的重复构造函数警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19890053/

相关文章:

delphi - 帕斯卡 : Delphi Length String Command Error

Delphi 7 更新连接表

c# - TransactionScope 在用于数据库单元测试时导致 TransactionManagerCommunicationException

delphi - 如何保持多个项目的使用列表相同

delphi - BDS2006 中的 GetVersionExW 错误

java - Robolectric测试: can not get the locale

c# - 寻找 PDF 文件解析器

unit-testing - 集成测试-可以正确完成吗?

c# - 单元测试数据库修改函数?

c# - 我应该在单元测试中使用 AutoMapper 吗?