# Unit testing framework recommendation

**URL:** https://forum.ada-lang.io/t/unit-testing-framework-recommendation/1736
**Category:** General
**Created:** [January 21, 2025, 2:58pm UTC](https://forum.ada-lang.io/t/unit-testing-framework-recommendation/1736 "2025-01-21T14:58:05Z")
**Posts on this page:** 3
**Page:** 2

<div class="post-metadata">

### Author: ![krischik](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/krischik/32/420_2.png) [@krischik](https://forum.ada-lang.io/u/krischik)
#### Post date: [February 28, 2025, 6:24pm UTC](https://forum.ada-lang.io/t/unit-testing-framework-recommendation/1736/21 "2025-02-28T18:24:23Z")

</div>

> [@Trescott](#):
>
> Then some tool can search for those made-up `pragma`s.

Interesting. But how is that any different to searching for special comments like gnatdoc does? With comments having the benefit of not creating warnings?

---

<div class="post-metadata">

### Author: ![Trescott](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/t/a5b964/32.png) [@Trescott](https://forum.ada-lang.io/u/Trescott)
#### Post date: [March 3, 2025, 4:58am UTC](https://forum.ada-lang.io/t/unit-testing-framework-recommendation/1736/22 "2025-03-03T04:58:44Z")

</div>

The only disadvantage, that I can think of, for using `pragma` instead of a comment is the warning. (But I think most compilers have a command line switch to disable this warning. GNAT uses `-gnatwG` to “Suppress warnings on unrecognized pragmas.”)

However, there are several advantages, in my opinion, to using a `pragma`:

1. `pragma` does not look like a comment. Readers of the program will immediately know that it has significance beyond informing the reader.
2. Existing Ada source parsers may pick it up as part of the code. (Such as libadalang.) Building tools using such parsers could be simplified because a custom parser would not be needed. (I expect parsers will pickup all `pragma` or none of them, as it would not know which `pragma` are vaild for you compiler.)
3. If a compiler wanted to add support for the `pragma`, it would be easy to implement, in contrast to adding support for magic comments.
4. Finally, in my opinion, using a `pragma` feels more inline with the Ada philosophy.

---

<div class="post-metadata">

### Author: ![mgrojo](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/mgrojo/32/15_2.png) [@mgrojo](https://forum.ada-lang.io/u/mgrojo)
#### Post date: [March 12, 2025, 8:15pm UTC](https://forum.ada-lang.io/t/unit-testing-framework-recommendation/1736/23 "2025-03-12T20:15:52Z")

</div>

> [@pyj](#):
>
> ```ada
> pragma Unit_Test (Test_Function);
> -- Maybe it should be an function instead, idk.
> procedure Test_Function is begin ... end;
> 
> ```

> [@Trescott](#):
>
> The only disadvantage, that I can think of, for using `pragma` instead of a comment is the warning.

There is a nice way to do this with GNAT, the [pragma Annotate](https://gcc.gnu.org/onlinedocs/gnat_rm/Pragma-Annotate.html):

```ada
 pragma Annotate (Unit_Test, Test_Function);
-- Maybe it should be an function instead, idk.
procedure Test_Function is begin ... end;

```

This pragma is used by AdaCore tools, but according to the documentation, and my experience, you don’t get any warning.

> This pragma is intended for use by external tools, including ASIS. The use of pragma Annotate does not affect the compilation process in any way.

And you can even get the entity name checked if you use the `Entity` parameter:

```ada
 pragma Annotate (Unit_Test, Entity => Test_Funttion);
-- Maybe it should be an function instead, idk.
procedure Test_Function is begin ... end;

```

```ada
test.adb:14:42: error: "Test_Funttion" is undefined
test.adb:14:42: error: possible misspelling of "Test_Function"

```

[Previous page](https://forum.ada-lang.io/t/unit-testing-framework-recommendation/1736.md?page=1)
