also looking at this
test: make CI exercise maintained integrations
#18
16 files
+390
-139
| @@ -1,19 +1,51 @@ | ||
| 1 | 1 | const std = ; |
| 2 | const ztf = ; | |
| 2 | 3 | |
| 3 | // Placeholder tests for suite module | |
| 4 | // TODO: Implement comprehensive tests for test suite management | |
| 4 | fn passingTest(_: std.mem.Allocator) !void {} | |
| 5 | fn hookOne(_: std.mem.Allocator) !void {} | |
| 6 | fn hookTwo(_: std.mem.Allocator) !void {} | |
| 5 | 7 | |
| 6 | test "suite creation and management" { | |
| 7 | // Test TestSuite initialization | |
| 8 | try std.testing.expect(true); | |
| 8 | test "suite owns tests and nested suites" { | |
| 9 | const allocator = std.testing.allocator; | |
| 10 | const parent = try ztf.TestSuite.init(allocator, "parent"); | |
| 11 | defer parent.deinit(); | |
| 12 | const child = try ztf.TestSuite.init(allocator, "child"); | |
| 13 | try parent.addTest(ztf.TestCase.init("one", passingTest)); | |
| 14 | try child.addTest(ztf.TestCase.init("two", passingTest)); | |
| 15 | try parent.addSuite(child); | |
| 16 | try std.testing.expectEqual(@as(usize, 2), parent.countTests()); | |
| 17 | try std.testing.expectEqual(parent, child.parent.?); | |
| 9 | 18 | } |
| 10 | 19 | |
| 11 | test "suite nested describe blocks" { | |
| 12 | // Test nested test suites | |
| 13 | try std.testing.expect(true); | |
| 20 | test "nested hooks preserve before and after ordering" { | |
| 21 | const allocator = std.testing.allocator; | |
| 22 | const parent = try ztf.TestSuite.init(allocator, "parent"); | |
| 23 | defer parent.deinit(); | |
| 24 | const child = try ztf.TestSuite.init(allocator, "child"); | |
| 25 | try parent.addSuite(child); | |
| 26 | try parent.addBeforeEach(hookOne); | |
| 27 | try child.addBeforeEach(hookTwo); | |
| 28 | try parent.addAfterEach(hookOne); | |
| 29 | try child.addAfterEach(hookTwo); | |
| 30 | ||
| 31 | var before = try child.getAllBeforeEachHooks(allocator); | |
| 32 | defer before.deinit(allocator); | |
| 33 | var after = try child.getAllAfterEachHooks(allocator); | |
| 34 | defer after.deinit(allocator); | |
| 35 | try std.testing.expectEqual(hookOne, before.items[0]); | |
| 36 | try std.testing.expectEqual(hookTwo, before.items[1]); | |
| 37 | try std.testing.expectEqual(hookTwo, after.items[0]); | |
| 38 | try std.testing.expectEqual(hookOne, after.items[1]); | |
| 14 | 39 | } |
| 15 | 40 | |
| 16 | test "suite skip and only functionality" { | |
| 17 | // Test skip and only modifiers | |
| 18 | try std.testing.expect(true); | |
| 41 | test "suite skip and only state inherits from parents" { | |
| 42 | const allocator = std.testing.allocator; | |
| 43 | const parent = try ztf.TestSuite.init(allocator, "parent"); | |
| 44 | defer parent.deinit(); | |
| 45 | const child = try ztf.TestSuite.init(allocator, "child"); | |
| 46 | try parent.addSuite(child); | |
| 47 | parent.skip = true; | |
| 48 | parent.only = true; | |
| 49 | try std.testing.expect(child.shouldSkip()); | |
| 50 | try std.testing.expect(child.hasOnly()); | |
| 19 | 51 | } |