在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:playbook-ui/playbook-ios开源软件地址:https://github.com/playbook-ui/playbook-ios开源编程语言:Swift 97.7%开源软件介绍:A library for isolated developing UI components and automatically taking snapshots of them. Playbook
Components built by using Besides, snapshots of each component can be automatically generated by unit tests, and visual regression testing can be performed using arbitrary third-party tools. For complex modern app development, it’s important to catch UI changes more sensitively and keep improving them faster. UsagePlaybook
Playbook.default.addScenarios(of: "Home") {
Scenario("CategoryHome", layout: .fill) {
CategoryHome().environmentObject(UserData.stub)
}
Scenario("LandmarkList", layout: .fill) {
NavigationView {
LandmarkList().environmentObject(UserData.stub)
}
}
Scenario("UIView red", layout: .fixed(length: 100)) {
let view = UIView()
view.backgroundColor = .red
return view
}
}
struct HomeScenarios: ScenarioProvider {
static func addScenarios(into playbook: Playbook) {
playbook.addScenarios(of: "Home") {
Scenario("CategoryHome", layout: .fill) {
CategoryHome().environmentObject(UserData.stub)
}
}
}
}
struct AllScenarios: ScenarioProvider {
static func addScenarios(into playbook: Playbook) {
playbook.add(HomeScenarios.self)
}
} You can use the Scenario("MapView", layout: .fill) { context in
MapView(coordinate: landmarkData[10].locationCoordinate) {
// This closure will called after the map has completed to render.
context.snapshotWaiter.fulfill()
}
.onAppear(perform: context.snapshotWaiter.wait)
} PlaybookUI
PlaybookGalleryThe component visuals are listed and displayed.
PlaybookCatalogThe UI that search and select a scenario in a drawer. It's more similar to
How to Save Snapshot ImagesTo save snapshot images to the photo library from the share button on each UI, PlaybookSnapshotScenarios can be tested by the instance of types conform to final class SnapshotTests: XCTestCase {
func testTakeSnapshot() throws {
let directory = ProcessInfo.processInfo.environment["SNAPSHOT_DIR"]!
try Playbook.default.run(
Snapshot(
directory: URL(fileURLWithPath: directory),
clean: true,
format: .png,
keyWindow: UIApplication.shared.windows.first { $0.isKeyWindow },
devices: [.iPhone11Pro(.portrait)]
)
)
}
} PlaybookAccessibilitySnapshotAn extension to Integration with Third-party ToolsThe generated snapshot images can be used for more advanced visual regression testing by using a variety of third party tools. percyreg-viz/reg-suitRequirements
InstallationPlaybook features are separated into the following frameworks.
CocoaPodsAdd the following to your target 'YourPlaybook' do
pod 'Playbook'
pod 'PlaybookUI'
target 'YourPlaybookTests' do
inherit! :search_paths
pod 'PlaybookSnapshot'
end
end CarthageAdd the following to your
Swift Package ManagerSelect Xcode menu
Note: Currently, SwiftPM doesn't support specifying the OS version for each library, so only LicensePlaybook is released under the Apache 2.0 License. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论