How can I specify functions or procedures GNATTest should auomatically generate a test case for

五迷三道 提交于 2021-02-09 00:46:33

问题


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"?


回答1:


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

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

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

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

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

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.



来源:https://stackoverflow.com/questions/57907022/how-can-i-specify-functions-or-procedures-gnattest-should-auomatically-generate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!