"More Data => Better tests"
Part of the Alchemy Series, this library makes it easier to test your code by providing generators for common Objects and Data.
Introducing randomized data to tests helps improve test quality by assuring that your code can work over a wide range of data values, and not just what you hard-code in. It also increases confidence that code will work in a variety of circumstances.
To use, simply add the following Carthage dependency
github "SirWellington/alchemy-generator-swift" "develop"
//A number in the range [-50, 50) let anInteger: Int = AlchemyGenerator.integers(from: -50, to: 50)
//Get any positive long let somePositiveNumber: Long = AlchemyGenerator.positiveLong() //alternative way using computed properties somePositiveNumber = AlchemyGenerator.Longs.positive
//A double in the range [0.1, 1999.0] let double = AlchemyGenerator.doubles(from: 0.1, to: 1999.0)
Randomized strings can be conveniently accessed using computed properties in the
Uses the Latin Alphabet, a-z | A-Z
let alphabetical: String = AlchemyGenerator.alphabeticalString(ofSize: 10)
Uses the Latin Alphabet, and numbers 0-9.
let alphanumeric = AlchemyGenerator.alphanumericString()
Creates strings composed of the digits 0-9.
let zipCode = AlchemyGenerator.numericString(ofSize: 5)
let hex = AlchemyGenerator.hexadecimalString(ofSize: 10) //Uses a computed property let anotherRandomHex = AlchemyGenerator.Strings.hex
These strings may have unicode characters as well. These are great for testing against international character sets as well.
let anyString = AlchemyGenerator.Strings.anyString let anyStringSized = AlchemyGenerator.anyString(ofSize: 13)
Guaranteed unique strings
From Fixed Set
Strings can be generated from a preselected set of String values.
let stringFromList = AlchemyGenerator.stringFrom(list: ["admit", "learn", "let in", "hear", "listen", "obey"])
Dates and Times
Our code very often works people, and information about them
String name = names().get(); int age = one(adultAges()); String phoneNumber = one(phoneNumberStrings()); String email = one(emails());
POSOs (plain old swift objects) are dumb data objects, that is they tend to contain no functionality other than getters/setters and value methods
Alchemy Generator provides Automatic Generation of POJOs.
Let's say you have a class like
- Swift 3
- XCode 8
Feature Requests are definitely welcomed! Please drop a note in Issues.
- Initial Public Release
This Software is licensed under the Apache 2.0 License