How to determine if code is being run during testing?

Is there a way to tell if the code is being run during testing? I have some functionality that I’d like to reduce the scope of during unit tests for performance reasons

I found it while going through the Compile Variables

const is_test = @import("builtin").is_test;

test {
    const expect = @import("std").testing.expect;
    try expect(is_test);
}

2 Likes