New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fixtures for tests #1

Merged
merged 2 commits into from Oct 6, 2018
Jump to file or symbol
Failed to load files and symbols.
+56 −16
Diff settings

Always

Just for now

@@ -11,10 +11,12 @@
3F7D98F22168BF3200746D76 /* Swift_Fixtures_Example.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F7D98E42168BF3100746D76 /* Swift_Fixtures_Example.h */; settings = {ATTRIBUTES = (Public, ); }; };
3F7D98FC2168C15000746D76 /* Pizza.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F7D98FB2168C15000746D76 /* Pizza.swift */; };
3F7D98FE2168C32A00746D76 /* PizzaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F7D98FD2168C32A00746D76 /* PizzaTests.swift */; };
3F7D99002168C42300746D76 /* Pizza+Fixture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F7D98FF2168C42300746D76 /* Pizza+Fixture.swift */; };
3F7D99022168C5E200746D76 /* Address.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F7D99012168C5E200746D76 /* Address.swift */; };
3F7D99042168C63800746D76 /* Order.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F7D99032168C63800746D76 /* Order.swift */; };
3F7D99062168C67C00746D76 /* Beverage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F7D99052168C67C00746D76 /* Beverage.swift */; };
3F7D99082168C6F800746D76 /* OrderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F7D99072168C6F800746D76 /* OrderTests.swift */; };
3F7D990C2168C95300746D76 /* Order+Fixture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F7D990B2168C95300746D76 /* Order+Fixture.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -35,10 +37,12 @@
3F7D98F12168BF3200746D76 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3F7D98FB2168C15000746D76 /* Pizza.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pizza.swift; sourceTree = "<group>"; };
3F7D98FD2168C32A00746D76 /* PizzaTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PizzaTests.swift; sourceTree = "<group>"; };
3F7D98FF2168C42300746D76 /* Pizza+Fixture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Pizza+Fixture.swift"; sourceTree = "<group>"; };
3F7D99012168C5E200746D76 /* Address.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Address.swift; sourceTree = "<group>"; };
3F7D99032168C63800746D76 /* Order.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Order.swift; sourceTree = "<group>"; };
3F7D99052168C67C00746D76 /* Beverage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Beverage.swift; sourceTree = "<group>"; };
3F7D99072168C6F800746D76 /* OrderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderTests.swift; sourceTree = "<group>"; };
3F7D990B2168C95300746D76 /* Order+Fixture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Order+Fixture.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -96,8 +100,10 @@
3F7D98EE2168BF3200746D76 /* Swift-Fixtures-ExampleTests */ = {
isa = PBXGroup;
children = (
3F7D990B2168C95300746D76 /* Order+Fixture.swift */,
3F7D98F12168BF3200746D76 /* Info.plist */,
3F7D99072168C6F800746D76 /* OrderTests.swift */,
3F7D98FF2168C42300746D76 /* Pizza+Fixture.swift */,
3F7D98FD2168C32A00746D76 /* PizzaTests.swift */,
);
path = "Swift-Fixtures-ExampleTests";
@@ -224,7 +230,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3F7D990C2168C95300746D76 /* Order+Fixture.swift in Sources */,
3F7D99082168C6F800746D76 /* OrderTests.swift in Sources */,
3F7D99002168C42300746D76 /* Pizza+Fixture.swift in Sources */,
3F7D98FE2168C32A00746D76 /* PizzaTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -0,0 +1,26 @@
//
// Order+Fixture.swift
// Swift-Fixtures-ExampleTests
//
// Created by Gio on 6/10/18.
// Copyright © 2018 mokacoding. All rights reserved.
//
@testable import Swift_Fixtures_Example
extension Order {
static func fixture(
pizzas: [Pizza] = [.fixture()],
drinks: [Beverage] = [Water()],
address: Address = Address(
street: "1 Infinity Loop",
tow: "Cupertino",
state: "California",
postCode: "95014",
country: "USA"
)
) -> Order {
return Order(pizzas: pizzas, drinks: drinks, address: address)
}
}
@@ -12,20 +12,7 @@ import XCTest
class OrderTests: XCTestCase {
func testItemsCount() {
let pizza = Pizza(
name: "Margherita",
toppings: [TomatoSauce(), Mozzarella(), Salami(extraSpicy: true)]
)
let deliveryAddress = Address(
street: "1 Infinity Loop",
tow: "Cupertino",
state: "California",
postCode: "95014",
country: "USA"
)
let drinks = [Water()]
let order = Order(pizzas: [pizza], drinks: drinks, address: deliveryAddress)
let order = Order.fixture(pizzas: [.fixture()], drinks: [Water()])
XCTAssertEqual(order.itemsCount, 2)
}
@@ -0,0 +1,19 @@
//
// Pizza+Fixture.swift
// Swift-Fixtures-ExampleTests
//
// Created by Gio on 6/10/18.
// Copyright © 2018 mokacoding. All rights reserved.
//
@testable import Swift_Fixtures_Example
extension Pizza {
static func fixture(
name: String = "name",
toppings: [Topping] = [TomatoSauce(), Mozzarella()]
) -> Pizza {
return Pizza(name: name, toppings: toppings)
}
}
@@ -12,13 +12,13 @@ import XCTest
class PizzaTests: XCTestCase {
func testIsVegetarianWithVegetarianToppings() {
let pizza = Pizza(name: "name", toppings: [TomatoSauce(), Mozzarella()])
let pizza = Pizza.fixture(toppings: [TomatoSauce(), Mozzarella()])
XCTAssertTrue(pizza.isVegeterian)
}
func testIsVegetarianWithNonVegetarianToppings() {
let pizza = Pizza(name: "name", toppings: [TomatoSauce(), Mozzarella(), Salami(extraSpicy: true)])
let pizza = Pizza.fixture(toppings: [TomatoSauce(), Mozzarella(), Salami(extraSpicy: true)])
XCTAssertFalse(pizza.isVegeterian)
}
ProTip! Use n and p to navigate between commits in a pull request.