#Testing cleanup
1 messages · Page 1 of 1 (latest)
what do you mean by cleaned up
I mean if I have something like ```foo_test.zig
const std = @import("std");
const foo = @import("foo");
const my_foo: foo.Foo = undefined;
test "init" {
my_foo = foo.init();
}
test "other_stuff" {
try std.testing.expectEqual(.bar, my_foo.other_stuff());
}
test "deinit" {
my_foo.deinit();
}```
Is there a way that I can make it so that I can defer the deinit test?
you should create a foo for each test
the point of unit tests is to be individually reproducible
alr
there’s no order guarantee for the tests, for the aformentioned reason
Ok, then can I have ```
const std = @import("std");
const allocator = std.testing.allocator
test {
...
}
or should I write allocator in each test
the testing allocator is initialized and deinited outside of running the tests
writing it each time wouldn’t change anything
alr