# Comptime test names

**URL:** <https://ziggit.dev/t/comptime-test-names/13503>\
**Category:** Help\
**Tags:** language\
**Created:** [December 14, 2025, 12:37am UTC](https://ziggit.dev/t/comptime-test-names/13503 "2025-12-14T00:37:39Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Sze](https://ziggit.dev/user_avatar/ziggit.dev/sze/32/496_2.png) [@Sze](https://ziggit.dev/u/Sze)\
**Post date:** [December 14, 2025, 1:01pm UTC](https://ziggit.dev/t/comptime-test-names/13503/10 "2025-12-14T13:01:21Z")

</div>

You can make a name appear as part of the name of a parent namespace, by making that parent namespace into a generic which takes that name as a parameter, I would only use this if the set of names can’t be enumerated by hand, for example (maybe) in this case (if the file names were defined via a build option or similar):

> [@Generating Tests at Comptime](https://ziggit.dev/t/generating-tests-at-comptime/6473/5):
>
> If you want the names to show up in the error message the only way I can think of is to make the name a comptime/generic parameter of a parent namespace and have the test namespaced underneath that, that way the name will show up in error messages. const std = @import("std"); pub fn Test(comptime name: []const u8, Def: type) type { return struct { const reference = name; const def = Def; const Self = @This(); test Self { try Def.impl(); …

Here I would suggest to just write it out:

```zig
test "alpha_1" {
    try test_helper("alpha", 1);
}
test "alpha_2" {
    try test_helper("alpha", 2);
}
test "beta_1" {
    try test_helper("beta", 1);
}
test "beta_2" {
    try test_helper("beta", 2);
}
// or
test "alpha/beta" {
    try test_helper("alpha", 1);
    try test_helper("alpha", 2);
    try test_helper("beta", 1);
    try test_helper("beta", 2);
}

```

I don’t think Zig needs to be used in a (often) Lisp like manner, where you write a macro for every single repeating thing, even in Lisp it can be annoying when people go overboard with trying to remove any kind of repetition.

If your actual use-case is more complicated than what you gave as example, then my answer might be different.

Sometimes it also may make sense to write a generator, which writes it out which is used via the buildsystem (So it uses code generation instead of comptime). I think if you need to generate many such tests then code generation could be quite a bit better.

---

_[View the full topic](https://ziggit.dev/t/comptime-test-names/13503)._
