Last active
February 10, 2021 09:50
-
-
Save dduan/c9781e51c13ae4a0f7eb to your computer and use it in GitHub Desktop.
This script takes a JSON text file with content in {"string:["a","b",…]} format and generates Quick/BDD style test outlines.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env xcrun swift | |
/* | |
usage: | |
1. chmod +x QuickOutline.swift | |
2. ./QuickOutline.swift outline.json | |
this will generate BDD/[Quick](https://github.com/Quick/Quick) style test outlines according to outline.json | |
an example outline.json: | |
{"Test description A": ["test a1","test a2"], "Test Description B":["test b"]} | |
The following would be the output from the example: | |
describe("Test Description B") { | |
it("test b") { | |
} | |
} | |
describe("Test description A") { | |
it("test a1") { | |
} | |
it("test a2") { | |
} | |
} | |
*/ | |
import Foundation | |
if let let fileData = NSData(contentsOfFile:Process.arguments[1]), | |
let JSONData = NSJSONSerialization.JSONObjectWithData(fileData, options:NSJSONReadingOptions(0), error:nil) as? [String:[String]] { | |
for (description, its) in JSONData { | |
println("describe(\"\(description)\") {") | |
for it in its { | |
println(" it(\"\(it)\") {") | |
println(" }") | |
} | |
println("}") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment