如何指定函数或过程,GNATTest应该自动生成一个测试用例 [英] How can I specify functions or procedures GNATTest should auomatically generate a test case for

查看:217
本文介绍了如何指定函数或过程,GNATTest应该自动生成一个测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个巨大的代码包(主要以ada编写),这是一个极端的混乱.到目前为止,尚未应用任何单元测试,并且对于所有现有代码,都不得实施单元测试.但是我们的团队决定,所有新代码都应与测试一起实施.在GPS中,可以让GNATtest自动为项目中的所有功能和程序生成测试程序.但是按照书面规定,我们必须从这种自动生成中排除所有旧代码.

I'm working on a huge code package (written dominantly in ada), which is an extreme mess. No Unit Tests are applied so far and for all the existing code, Unit tests must not be implemented. But our Team decided, that all the new code should be implemented together with tests. Within GPS there is the possibility to let GNATtest automatically generate test procedures for all functions and procedures in the project. But as written, we have to exclude all of the old code from this automated genereation.

是否可以将功能和过程标记为需要测试"?

Is there a way to tag functions and procedures as "need to be tested"?

推荐答案

您可以通过添加参数--test-case-only来指示gnattest仅针对选定的过程或函数创建测试.我不确定如何在GPS中进行设置.终端中的整个命令可以看起来如下:

You can instruct gnattest to create tests only for selected procedures or functions by adding parameter --test-case-only. I'm not sure how to set it in GPS. Whole command in terminal can looks that:

gnattest -P yourproject.gpr --test-case-only

您还可以将此参数添加到您的.gpr文件中:

You can also add this parameter to your .gpr file:

    package GnatTest is
       for GnatTest_Switches use ("--test-case-only");
    end GnatTest;

设置时,必须添加方面(或杂注)Test_Case.例如:

When you set it, you have to add aspect (or pragma) Test_Case. For example:

procedure Something with
 Test_Case => ("Test_Something", Robustness);

您可以在 GNAT文档.链接是指向编译指示的定义,但是方面的工作原理完全相同.

You can find more information about this aspect/pragma in GNAT Documentation. Link is to pragma definition, but aspect works exactly in that same way.

这篇关于如何指定函数或过程,GNATTest应该自动生成一个测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆