我有以下.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警告] W1029重复构造函数'TExpectation.CreateAfter' C ++ [DCC警告]将无法使用相同的参数 W1029复制构造函数'TExpectation.CreateAfterWhen'with 相同的参数将无法从C ++ [DCC警告] W1029中获得 复制构造函数'TExpectation.CreateAtLeastOnce'具有相同的 参数将无法从C ++
中获得
但如果我删除了行FMessageDLG : TMock<IDlg>;
,那么警告就会消失
如何解决这个问题?
答案 0 :(得分:3)
警告意味着它的内容。如果您对C ++兼容性不感兴趣,那么只需禁用警告即可。其他任何东西都需要更改TEXpectation的定义,以使它的构造函数不同于参数列表而不仅仅是名称。
答案 1 :(得分:1)
delphi项目中的Delphi Mocks和C ++ Compatibility Compiler标志相互不兼容。只需在“编译器”设置中关闭“ C ++兼容性”选项即可。请记住,Delphi有多种用途。此警告在某些使用场景中有目的,但在大多数delphi用户的日常工作中却没有。您可以禁用警告。
{$WARN DUPLICATE_CTOR_DTOR OFF}
根据需要将其添加到PROJECT(.dpr)范围或单位范围。