Skip to content

Commit c8dc852

Browse files
committed
Refactor SwiftGitX tests to use new testing framework and improve initialization/shutdown checks
1 parent a0b878c commit c8dc852

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

Tests/SwiftGitXTests/SwiftGitXTests.swift

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SwiftGitX
2+
import Testing
23
import XCTest
34

45
class SwiftGitXTestCase: XCTestCase {
@@ -24,20 +25,54 @@ class SwiftGitXTestCase: XCTestCase {
2425
}
2526
}
2627

27-
final class SwiftGitXTests: SwiftGitXTestCase {
28-
func testSwiftGitXInitialize() throws {
29-
// Initialize the SwiftGitX library
28+
/// Base class for SwiftGitX tests to initialize and shutdown the library
29+
///
30+
/// - Important: Inherit from this class to create a test suite.
31+
class SwiftGitXTest {
32+
static var directory: String {
33+
String(describing: Self.self)
34+
}
35+
36+
init() throws {
3037
try SwiftGitX.initialize()
38+
}
39+
40+
deinit {
41+
_ = try? SwiftGitX.shutdown()
42+
}
43+
}
44+
45+
// Test the SwiftGitX struct to initialize and shutdown the library
46+
@Suite("SwiftGitX Tests", .tags(.swiftGitX), .serialized)
47+
struct SwiftGitXTests {
48+
@Test("Test SwiftGitX Initialize")
49+
func testSwiftGitXInitialize() async throws {
50+
// Initialize the SwiftGitX library
51+
let count = try SwiftGitX.initialize()
52+
53+
// Check if the initialization count is valid
54+
#expect(count > 0)
55+
}
3156

57+
@Test("Test SwiftGitX Shutdown")
58+
func testSwiftGitXShutdown() async throws {
3259
// Shutdown the SwiftGitX library
33-
try SwiftGitX.shutdown()
60+
let count = try SwiftGitX.shutdown()
61+
62+
// Check if the shutdown count is valid
63+
#expect(count >= 0)
3464
}
3565

66+
@Test("Test SwiftGitX Version")
3667
func testVersion() throws {
3768
// Get the libgit2 version
3869
let version = SwiftGitX.libgit2Version
3970

4071
// Check if the version is valid
41-
XCTAssertEqual(version, "1.8.0")
72+
#expect(version == "1.8.0")
4273
}
4374
}
75+
76+
extension Testing.Tag {
77+
@Tag static var swiftGitX: Self
78+
}

0 commit comments

Comments
 (0)