11import SwiftGitX
2+ import Testing
23import XCTest
34
45class 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