Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hylo-lang/generateswiftxctestmain
A tool that generates a main.swift that runs XCTestCases found in Swift source files.
https://github.com/hylo-lang/generateswiftxctestmain
Last synced: 29 days ago
JSON representation
A tool that generates a main.swift that runs XCTestCases found in Swift source files.
- Host: GitHub
- URL: https://github.com/hylo-lang/generateswiftxctestmain
- Owner: hylo-lang
- License: apache-2.0
- Created: 2024-02-23T20:27:59.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-09-19T00:24:28.000Z (5 months ago)
- Last Synced: 2025-01-06T22:56:08.205Z (about 1 month ago)
- Language: Swift
- Size: 36.1 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GenerateSwiftXCTestMain
A tool that finds `XCTestCase`s and their `testXXX` methods and generates a `main.swift` to run
them.## Why
On Apple platforms, test discovery is built into the OS and also works for tests written in
Objective-C. On other platforms, it is built into the Swift Package Manager, but for other build
systems, you have to write (and maintain) the main function by hand. Or you could use a tool like
this one.## How
[FindSwiftXCTest](https://github.com/hylo-lang/SwiftCMakeXCTesting) shows how this tool can be
integrated with CMake.## Limitations
This tool parses the Swift test files using the official Swift parser, but doesn't know about
conditional compilation settings or how to expand Swift macros, and use of those features outside
the scope of test method bodies could produce unpredictable results.## Build and Test
There are two methods:
1. **Swift Package Manager**: `swift test`
2. **CMake**: ````sh
mkdir path/to/build/directory
cmake -DBUILD_TESTING=1 -GNinja -S . -B path/to/build/directory
cmake --build path/to/build/directory
ctest -V --test-dir path/to/build/directory
```