Quark is a Swift library that generates tests for you.
It's designed to make testing your Swift applications more efficient.
Generates tests based on the macros and parameters:
- Localization tests: Automatically test your localized strings
- Snapshot tests: Generate snapshot tests for your views
#Quark([.localize, .snapshot]) {
ContentView()
}
Simple as that! ✨
- iOS 16.4+
- Swift 6.0+
- Xcode 15+
Add Quark to your project using Swift Package Manager:
dependencies: [
.package(url: "https://github.com/sorunokoe/Quark.git", from: "0.1.0")
]
.target(
name: "Example",
dependencies: [
.product(name: "Quark", package: "Quark")
]
),
.testTarget(
name: "ExampleTests",
dependencies: [
"Example",
.product(name: "QuarkTesting", package: "Quark")
],
plugins: [
.plugin(name: "QuarkTestsPlugin", package: "Quark")
]
)
import SwiftUI
import Quark
struct ContentView: View {
var body: some View {
Text("Hello World!")
}
}
#Preview {
ContentView()
}
#Quark([.localize, .snapshot]) {
ContentView()
}
Separate usage:
import SwiftUI
import Quark
struct ContentView: View {
var body: some View {
Text("Hello World!")
}
}
#Preview {
ContentView()
}
#Quark([.localize]) {
ContentView()
}
#Quark([.snapshot]) {
ContentView()
}
Sometimes there is no need for localization. In that case, use the .noLocalizationNeeded()
modifier. Example:
import Quark
import SwiftUI
struct MedeDiaryView: View {
var friends: [String]
var body: some View {
VStack(alignment: .leading, spacing: 20) {
Text("welcome_from_mede")
.font(.title)
VStack(alignment: .leading, spacing: 8) {
Text("my_friends")
.bold()
ForEach(friends, id: \.self) { friend in
Text(friend)
.noLocalizationNeeded() // <--- skip the test
}
Button("update") {}
}
}
}
}
#Preview {
MedeDiaryView(friends: ["Tapo", "Bird", "Mammut"])
}
#Quark([.localize]) {
MedeDiaryView(friends: ["Tapo", "Bird", "Mammut"])
}
The main library that provides macros.
Note
Add as a dependency only to a target (not testTarget).
Additional testing utilities and helpers for writing tests.
Note
Add as a dependency only to a testTarget.
Build tool plugin for enhanced testing capabilities.
Note
Add as a plugin only to a testTarget.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Yeskendir Salgara - LinkedIn
Project Link: https://github.com/sorunokoe/Quark