Skip to content

Instantly share code, notes, and snippets.

@dduan
Last active February 10, 2021 09:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dduan/c9781e51c13ae4a0f7eb to your computer and use it in GitHub Desktop.
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.
#!/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