简体   繁体   English

C ++ Builder 10.3 Rio-Testframework

[英]C++ Builder 10.3 Rio - Testframework

It seems that C++ builder 10.3. 看来C ++ Builder 10.3。 comes with a new testframework.hpp . 带有一个新的testframework.hpp The class Assert does not exist any longer. Assert类不再存在。

Can anyone tell me how to use this new framework? 谁能告诉我如何使用这个新框架?

I am desperate because I wrote a lot of code and obviously Rio is not really compatible. 我很绝望,因为我写了很多代码,显然Rio并不是真正兼容的。

for example the following code line, written in Builder 10.2.3, doesn't work any longer: 例如,以下用Builder 10.2.3编写的代码行将不再起作用:

Dunitx.Testframework::Assert::IsTrue (result == true);

I found the solution in the testframework.hpp - file. 我在testframework.hpp文件中找到了解决方案。 The usage is now a lot easier but you will have to know how to handle it. 现在使用起来要容易得多,但是您将必须知道如何处理它。 The description in the embaracdero help system is wrong and should be corrected. embaracdero帮助系统中的描述有误,应予以更正。

You seem to have found the TestFramework.hpp for DUnit . 您似乎已经找到DUnitTestFramework.hpp But it is obvious your code was using DUnitX before. 但是很明显,您的代码之前使用过DUnitX These are similar but incompatible test frameworks. 这些是相似但不兼容的测试框架。

To get the Dunitx.Testframework.hpp you need, simply add DUnitX.TestFramework.pas to your C++Builder test project (add it in the project manager) and completely re-build your project. 要获取所需的Dunitx.Testframework.hpp ,只需将DUnitX.TestFramework.pas添加到C ++ Builder测试项目中(将其添加到项目管理器中),然后完全重新构建您的项目。 The Pascal compiler will generate the necessary .hpp file for you. Pascal编译器将为您生成必要的.hpp文件。


But before you do all that, you may want to copy your project to a new folder , and load it from there, just to be sure. 但是在执行所有操作之前,您可能需要将项目复制到新文件夹 ,然后从那里加载它,只是为了确保。 That way, the older project will not be modified. 这样,较旧的项目将不会被修改。 Be sure to update all your paths in the project manager and C++ library settings too, if necessary. 如果需要,请确保也更新项目管理器和C ++库设置中的所有路径。


If you think DUnit is easier to use (I certainly do), then keep on using that. 如果您认为DUnit易于使用(我当然愿意),那么请继续使用它。 But you will have to rewrite some parts of your tests. 但是您将不得不重写测试的某些部分。 More info can be found in the Delphi help files (and on the web counterpart ) and on the DUnit website . 可以在Delphi帮助文件(和Web对应文件 )以及DUnit网站上找到更多信息。

DUnit was the former test framework for Delphi (hence the D), but at some time in the past, it was replaced by the more modern DUnitX . DUnit是Delphi(因此为D)的前一个测试框架,但在过去的某个时候,它被更现代的DUnitX取代。 But that uses some Delphi features (like Delphi attributes) that make it harder to use in C++Builder. 但这使用了某些Delphi功能(例如Delphi属性),使得在C ++ Builder中更难使用。 DUnit is still part of the RAD Studio installation. DUnit仍然是RAD Studio安装的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM