diff --git a/.gitignore b/.gitignore index 0645743d..c0a5e668 100644 --- a/.gitignore +++ b/.gitignore @@ -50,7 +50,9 @@ Carthage/Build # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md fastlane/report.xml +fastlane/reports/ fastlane/screenshots +.sonar # Code Injection # diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 00000000..66a9e481 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,33 @@ +# Fastlane runs swiftlint from one directory above where the Fastfile lives +# so make sure all the paths are relative in that regard. + +# Find all the available rules by running: +# swiftlint rules + +disabled_rules: + trailing_whitespace + +opt_in_rules: + +included: + - ./ +# paths to ignore during linting. Takes precedence over `included`. +excluded: + - Pods + +# configurable rules can be customized from this configuration file +# binary rules can set their severity level +line_length: + warning: 250 + error: 400 + +type_body_length: + warning: 300 + error: 400 + +file_length: + warning: 1000 + error: 1500 + +# reporter type (xcode, json, csv, checkstyle) +reporter: "json" \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..1216de0d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: objective-c # [sic]. Travis uses objective-c just to determine it needs to use the xcode cli +osx_image: xcode8.2 + +# cache: +# directories: +# - $HOME/.sonar + +branches: + # Only run push builds for the master branch. PR builds are run nevertheless + only: + - master + +before_install: + - echo $TRAVIS_SECURE_ENV_VARS + - ./fastlane/before_install.sh + +script: + - fastlane snapshot reset_simulators --force # Workaround for Travis bug https://github.com/travis-ci/travis-ci/issues/7031 + - ./fastlane/run.sh # Decide which lane to run + +notifications: + email: false diff --git a/Campus App.xcworkspace/contents.xcworkspacedata b/Campus App.xcworkspace/contents.xcworkspacedata index b540386d..9244834b 100644 --- a/Campus App.xcworkspace/contents.xcworkspacedata +++ b/Campus App.xcworkspace/contents.xcworkspacedata @@ -7,7 +7,4 @@ - - diff --git a/TUM Campus App.xcodeproj/project.pbxproj b/TUM Campus App.xcodeproj/project.pbxproj index 00ffd4d9..9115928a 100644 --- a/TUM Campus App.xcodeproj/project.pbxproj +++ b/TUM Campus App.xcodeproj/project.pbxproj @@ -116,8 +116,8 @@ 50200E221DF498B700B6FBE3 /* PersonDetail.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50200E211DF498B700B6FBE3 /* PersonDetail.storyboard */; }; 50200E241DF498F400B6FBE3 /* News.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50200E231DF498F400B6FBE3 /* News.storyboard */; }; 50200E261DF4992900B6FBE3 /* LectureDetail.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50200E251DF4992900B6FBE3 /* LectureDetail.storyboard */; }; - AE77B80EB6FCD1FB8FE4E213 /* Pods_Campus.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6A76425F01984CB2ADA54E78 /* Pods_Campus.framework */; }; - AF5B3DA4DA1C4EE21184536D /* Pods_TUM_Campus_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDFD9C3B4BE31FC4FE635CAC /* Pods_TUM_Campus_App.framework */; }; + 504C292C1E2BBB9C007583E2 /* MovieTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504C292B1E2BBB9C007583E2 /* MovieTests.swift */; }; + 50AFC9861E6C8ECF00E7886A /* Pods_Campus.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50AFC9851E6C8ECF00E7886A /* Pods_Campus.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -128,6 +128,13 @@ remoteGlobalIDString = 0E424F441BE16DBD00B5DFCB; remoteInfo = "TUM Campus App"; }; + 504C292E1E2BBB9C007583E2 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0E424F3D1BE16DBD00B5DFCB /* Project object */; + proxyType = 1; + remoteGlobalIDString = 0E424F441BE16DBD00B5DFCB; + remoteInfo = Campus; + }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -246,11 +253,11 @@ 50200E211DF498B700B6FBE3 /* PersonDetail.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = PersonDetail.storyboard; sourceTree = ""; }; 50200E231DF498F400B6FBE3 /* News.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = News.storyboard; sourceTree = ""; }; 50200E251DF4992900B6FBE3 /* LectureDetail.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LectureDetail.storyboard; sourceTree = ""; }; - 6A76425F01984CB2ADA54E78 /* Pods_Campus.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Campus.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 504C29291E2BBB9C007583E2 /* TUM Campus AppUnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "TUM Campus AppUnitTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 504C292B1E2BBB9C007583E2 /* MovieTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieTests.swift; sourceTree = ""; }; + 504C292D1E2BBB9C007583E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 50AFC9851E6C8ECF00E7886A /* Pods_Campus.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Pods_Campus.framework; path = "../../Library/Developer/Xcode/DerivedData/Campus_App-abdlonhukuicsjbpypswdmfoclts/Build/Products/Debug-iphonesimulator/Pods_Campus.framework"; sourceTree = ""; }; B036FEAD3E1DFC9E65802F03 /* Pods-Campus.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Campus.release.xcconfig"; path = "Pods/Target Support Files/Pods-Campus/Pods-Campus.release.xcconfig"; sourceTree = ""; }; - DAA3C0849116E2B4E4ED1F88 /* Pods-TUM Campus App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TUM Campus App.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TUM Campus App/Pods-TUM Campus App.debug.xcconfig"; sourceTree = ""; }; - EDFD9C3B4BE31FC4FE635CAC /* Pods_TUM_Campus_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TUM_Campus_App.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - F43AFC350BF52CC89A2FA259 /* Pods-TUM Campus App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TUM Campus App.release.xcconfig"; path = "Pods/Target Support Files/Pods-TUM Campus App/Pods-TUM Campus App.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -258,8 +265,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - AF5B3DA4DA1C4EE21184536D /* Pods_TUM_Campus_App.framework in Frameworks */, - AE77B80EB6FCD1FB8FE4E213 /* Pods_Campus.framework in Frameworks */, + 50AFC9861E6C8ECF00E7886A /* Pods_Campus.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -270,6 +276,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 504C29261E2BBB9C007583E2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -322,9 +335,10 @@ children = ( 0E424F471BE16DBE00B5DFCB /* TUM Campus App */, 0E424F5C1BE16DBE00B5DFCB /* TUM Campus AppUITests */, + 504C292A1E2BBB9C007583E2 /* TUM Campus AppUnitTests */, 0E424F461BE16DBE00B5DFCB /* Products */, F378FBA46D95A7D54F58A390 /* Pods */, - B3CA96B7ECEAA9D6B9C8C51A /* Frameworks */, + 50AFC9841E6C8ECE00E7886A /* Frameworks */, ); sourceTree = ""; }; @@ -333,6 +347,7 @@ children = ( 0E424F451BE16DBE00B5DFCB /* Campus.app */, 0E424F591BE16DBE00B5DFCB /* TUM Campus AppUITests.xctest */, + 504C29291E2BBB9C007583E2 /* TUM Campus AppUnitTests.xctest */, ); name = Products; sourceTree = ""; @@ -619,11 +634,19 @@ name = "Grade View"; sourceTree = ""; }; - B3CA96B7ECEAA9D6B9C8C51A /* Frameworks */ = { + 504C292A1E2BBB9C007583E2 /* TUM Campus AppUnitTests */ = { + isa = PBXGroup; + children = ( + 504C292B1E2BBB9C007583E2 /* MovieTests.swift */, + 504C292D1E2BBB9C007583E2 /* Info.plist */, + ); + path = "TUM Campus AppUnitTests"; + sourceTree = ""; + }; + 50AFC9841E6C8ECE00E7886A /* Frameworks */ = { isa = PBXGroup; children = ( - EDFD9C3B4BE31FC4FE635CAC /* Pods_TUM_Campus_App.framework */, - 6A76425F01984CB2ADA54E78 /* Pods_Campus.framework */, + 50AFC9851E6C8ECF00E7886A /* Pods_Campus.framework */, ); name = Frameworks; sourceTree = ""; @@ -631,8 +654,6 @@ F378FBA46D95A7D54F58A390 /* Pods */ = { isa = PBXGroup; children = ( - DAA3C0849116E2B4E4ED1F88 /* Pods-TUM Campus App.debug.xcconfig */, - F43AFC350BF52CC89A2FA259 /* Pods-TUM Campus App.release.xcconfig */, 44B8D8B1367F8E0398040486 /* Pods-Campus.debug.xcconfig */, B036FEAD3E1DFC9E65802F03 /* Pods-Campus.release.xcconfig */, ); @@ -680,6 +701,24 @@ productReference = 0E424F591BE16DBE00B5DFCB /* TUM Campus AppUITests.xctest */; productType = "com.apple.product-type.bundle.ui-testing"; }; + 504C29281E2BBB9C007583E2 /* TUM Campus AppUnitTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 504C29321E2BBB9C007583E2 /* Build configuration list for PBXNativeTarget "TUM Campus AppUnitTests" */; + buildPhases = ( + 504C29251E2BBB9C007583E2 /* Sources */, + 504C29261E2BBB9C007583E2 /* Frameworks */, + 504C29271E2BBB9C007583E2 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 504C292F1E2BBB9C007583E2 /* PBXTargetDependency */, + ); + name = "TUM Campus AppUnitTests"; + productName = "TUM Campus AppUnitTests"; + productReference = 504C29291E2BBB9C007583E2 /* TUM Campus AppUnitTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -701,6 +740,11 @@ LastSwiftMigration = 0820; TestTargetID = 0E424F441BE16DBD00B5DFCB; }; + 504C29281E2BBB9C007583E2 = { + CreatedOnToolsVersion = 8.2.1; + ProvisioningStyle = Automatic; + TestTargetID = 0E424F441BE16DBD00B5DFCB; + }; }; }; buildConfigurationList = 0E424F401BE16DBD00B5DFCB /* Build configuration list for PBXProject "TUM Campus App" */; @@ -718,6 +762,7 @@ targets = ( 0E424F441BE16DBD00B5DFCB /* Campus */, 0E424F581BE16DBE00B5DFCB /* TUM Campus AppUITests */, + 504C29281E2BBB9C007583E2 /* TUM Campus AppUnitTests */, ); }; /* End PBXProject section */ @@ -755,6 +800,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 504C29271E2BBB9C007583E2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -911,6 +963,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 504C29251E2BBB9C007583E2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 504C292C1E2BBB9C007583E2 /* MovieTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -919,6 +979,11 @@ target = 0E424F441BE16DBD00B5DFCB /* Campus */; targetProxy = 0E424F5A1BE16DBE00B5DFCB /* PBXContainerItemProxy */; }; + 504C292F1E2BBB9C007583E2 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 0E424F441BE16DBD00B5DFCB /* Campus */; + targetProxy = 504C292E1E2BBB9C007583E2 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -955,6 +1020,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_CODE_COVERAGE = YES; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BOOL_CONVERSION = YES; @@ -987,6 +1053,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.1; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -996,10 +1063,12 @@ }; 0E424F611BE16DBE00B5DFCB /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = B036FEAD3E1DFC9E65802F03 /* Pods-Campus.release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_CODE_COVERAGE = YES; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BOOL_CONVERSION = YES; @@ -1026,6 +1095,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -1042,6 +1112,21 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; DEVELOPMENT_TEAM = ZGV2PY25EN; + FRAMEWORK_SEARCH_PATHS = ( + "$(SRCROOT)/Pods", + "\"$PODS_CONFIGURATION_BUILD_DIR/ASWeekSelectorView\"", + "\"$PODS_CONFIGURATION_BUILD_DIR/AYSlidingPickerView\"", + "\"$PODS_CONFIGURATION_BUILD_DIR/Alamofire\"", + "\"$PODS_CONFIGURATION_BUILD_DIR/CalendarLib\"", + "\"$PODS_CONFIGURATION_BUILD_DIR/MCSwipeTableViewCell\"", + "\"$PODS_CONFIGURATION_BUILD_DIR/OSCache\"", + "\"$PODS_CONFIGURATION_BUILD_DIR/OrderedDictionary\"", + "\"$PODS_CONFIGURATION_BUILD_DIR/PZPullToRefresh\"", + "\"$PODS_CONFIGURATION_BUILD_DIR/SWXMLHash\"", + "\"$PODS_CONFIGURATION_BUILD_DIR/Sweeft\"", + "\"$PODS_CONFIGURATION_BUILD_DIR/SwiftyJSON\"", + "\"$PODS_CONFIGURATION_BUILD_DIR/TKSubmitTransition\"", + ); INFOPLIST_FILE = "TUM Campus App/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1079,6 +1164,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "de.tum.in.www1.ios15.TUM-Campus-AppUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; SWIFT_VERSION = 3.0; TEST_TARGET_NAME = "TUM Campus App"; USES_XCTRUNNER = YES; @@ -1092,12 +1178,46 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "de.tum.in.www1.ios15.TUM-Campus-AppUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; SWIFT_VERSION = 3.0; TEST_TARGET_NAME = "TUM Campus App"; USES_XCTRUNNER = YES; }; name = Release; }; + 504C29301E2BBB9C007583E2 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 44B8D8B1367F8E0398040486 /* Pods-Campus.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NONNULL = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + INFOPLIST_FILE = "TUM Campus AppUnitTests/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "de.tum.in.www1.ios15.TUM-Campus-AppUnitTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Campus.app/Campus"; + }; + name = Debug; + }; + 504C29311E2BBB9C007583E2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NONNULL = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + INFOPLIST_FILE = "TUM Campus AppUnitTests/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "de.tum.in.www1.ios15.TUM-Campus-AppUnitTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Campus.app/Campus"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -1128,6 +1248,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 504C29321E2BBB9C007583E2 /* Build configuration list for PBXNativeTarget "TUM Campus AppUnitTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 504C29301E2BBB9C007583E2 /* Debug */, + 504C29311E2BBB9C007583E2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 0E424F3D1BE16DBD00B5DFCB /* Project object */; diff --git a/TUM Campus App.xcodeproj/xcshareddata/xcschemes/TCA-CI.xcscheme b/TUM Campus App.xcodeproj/xcshareddata/xcschemes/TCA-CI.xcscheme new file mode 100644 index 00000000..39b6c381 --- /dev/null +++ b/TUM Campus App.xcodeproj/xcshareddata/xcschemes/TCA-CI.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TUM Campus App.xcodeproj/xcshareddata/xcschemes/TUM Campus App.xcscheme b/TUM Campus App.xcodeproj/xcshareddata/xcschemes/TUM Campus App.xcscheme new file mode 100644 index 00000000..abe87dbb --- /dev/null +++ b/TUM Campus App.xcodeproj/xcshareddata/xcschemes/TUM Campus App.xcscheme @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TUM Campus AppUITests/TUM_Campus_AppUITests.swift b/TUM Campus AppUITests/TUM_Campus_AppUITests.swift index 98e79e53..58a4e3ed 100644 --- a/TUM Campus AppUITests/TUM_Campus_AppUITests.swift +++ b/TUM Campus AppUITests/TUM_Campus_AppUITests.swift @@ -19,6 +19,7 @@ class TUM_Campus_AppUITests: XCTestCase { continueAfterFailure = false // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. XCUIApplication().launch() + sleep(10) // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. } @@ -28,9 +29,21 @@ class TUM_Campus_AppUITests: XCTestCase { super.tearDown() } - func testExample() { - // Use recording to get started writing UI tests. - // Use XCTAssert and related functions to verify your tests produce the correct results. + func testMoreToCalendarStartsAtTheCurrentDate() { + let app = XCUIApplication() + sleep(60) + app.tabBars.buttons["More"].tap() + sleep(10) + app.tables.staticTexts["Calendar"].tap() + + let date = Date() + let formatter = DateFormatter() + formatter.dateFormat = "MMMM dd" + let dateFormatted = formatter.string(from: date) + + print("The current date is \(dateFormatted)") + + XCTAssert(app.navigationBars[dateFormatted].exists) } } diff --git a/TUM Campus AppUnitTests/Info.plist b/TUM Campus AppUnitTests/Info.plist new file mode 100644 index 00000000..6c6c23c4 --- /dev/null +++ b/TUM Campus AppUnitTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/TUM Campus AppUnitTests/MovieTests.swift b/TUM Campus AppUnitTests/MovieTests.swift new file mode 100644 index 00000000..675e4053 --- /dev/null +++ b/TUM Campus AppUnitTests/MovieTests.swift @@ -0,0 +1,53 @@ +// +// TUM_Campus_AppUnitTests.swift +// TUM Campus AppUnitTests +// +// Created by Max Muth on 15/01/2017. +// Copyright © 2017 LS1 TUM. All rights reserved. +// + +import XCTest + +@testable import Campus + +class MovieTests: XCTestCase { + + var movies = [Movie]() + var manager = TumDataManager(user: nil) + + var testGetAllMoviesExpectation: XCTestExpectation? + + override func setUp() { + super.setUp() + } + + override func tearDown() { + super.tearDown() + } + + func testGetAllMovies() { + self.testGetAllMoviesExpectation = expectation(description: "Fetch movies and check whether there are > 0 movies") + manager.getMovies(self) + waitForExpectations(timeout: 5) { error in +// if let error = error { +// XCTFail("waitForExpectationsWithTimeout errored: \(error)") +// } + } + + } + +} + +extension MovieTests: TumDataReceiver { + + func receiveData(_ data: [DataElement]) { + for element in data { + if let movieElement = element as? Movie { + movies.append(movieElement) + } + } + XCTAssertNotNil(movies) + self.testGetAllMoviesExpectation?.fulfill() + } + +} diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 00000000..8b610925 --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,92 @@ +fastlane_version "2.19.1" + +default_platform :ios + +before_all do + if is_ci? + ensure_git_status_clean + end + sh 'mkdir reports || true' + sh 'mkdir DerivedData || true' +end + +################ +# PUBLIC LANES # +################ +desc 'Performs the integration into master. It Builds and tests, performs a static code analysis and updates the SonarQube dashboard.' +lane :integration do + test(code_coverage: true) + static_analysis + sonar_update_dashboard +end + +desc 'Performs tests and a static code analysis on the PR. Found issues are commented on the PR.' +lane :pull_request_from_upstream do + test(code_coverage: true) + static_analysis + sonar_github_pr_bot +end + +desc 'Runs the test suite.' +lane :pull_request_from_fork do + test(code_coverage: true) +end + + +######################## +# PRIVATE HELPER LANES # +######################## +private_lane :test do |options| + scan_args = { + scheme: "TCA-CI", + device: "iPhone 6 (10.2)", + configuration: "Debug", # Defaults to Release + code_coverage: options[:code_coverage] ? options[:code_coverage] : false, + # skip_build: true, # Should skip debug build before test build? Might break sonar + derived_data_path: "fastlane/DerivedData", + output_directory: "fastlane/reports", + custom_report_file_name: "scan-test.junit" + } + scan(scan_args) +end + +desc 'Performs a sonar analysis in preview mode and comments on the PR on Github.' +private_lane :sonar_github_pr_bot do + sonar_github_args = { + project_configuration_path: "sonar-project.properties", + sonar_runner_args: "-Dsonar.analysis.mode=preview" + + " -Dsonar.login=$SONAR_LOGIN_TOKEN" + + " -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST" + + " -Dsonar.github.oauth=$GITHUB_ACCESS_TOKEN" + + " -Dsonar.github.repository=$TRAVIS_REPO_SLUG", + } + sonar(sonar_github_args) +end + +desc 'Updates the SonarQube Server dashboard.' +private_lane :sonar_update_dashboard do + sonar_update_server_args = { + project_configuration_path: "sonar-project.properties", + sonar_runner_args: " -Dsonar.login=$SONAR_LOGIN_TOKEN" + } + sonar(sonar_update_server_args) +end + +desc 'Runs test coverage and swiftlint and provides data in a way sonar can use it afterwards.' +private_lane :static_analysis do + slather_args = { + proj: "TUM Campus App.xcodeproj", + scheme: "TCA-CI", + cobertura_xml: true, + jenkins: true, + build_directory: "fastlane/DerivedData", + output_directory: "fastlane/reports", + } + swiftlint_args = { + output_file: "fastlane/reports/swiftlint.txt", + ignore_exit_status: true + } + slather(slather_args) + # sh("cd .. && lizard ./TUM\ Campus\ App -l swift --xml > fastlane/reports/lizard-report.xml") + swiftlint(swiftlint_args) +end \ No newline at end of file diff --git a/fastlane/README.md b/fastlane/README.md new file mode 100644 index 00000000..095b2c4d --- /dev/null +++ b/fastlane/README.md @@ -0,0 +1,51 @@ +fastlane documentation +================ +# Installation + +Make sure you have the latest version of the Xcode command line tools installed: + +``` +xcode-select --install +``` + +## Choose your installation method: + + + + + + + + + + + + + + +
Homebrew +Installer Script +Rubygems +
macOSmacOSmacOS or Linux with Ruby 2.0.0 or above
brew cask install fastlaneDownload the zip file. Then double click on the install script (or run it in a terminal window).sudo gem install fastlane -NV
+# Available Actions +### integration +``` +fastlane integration +``` +Performs the integration into master. It Builds and tests, performs a static code analysis and updates the SonarQube dashboard. +### pull_request +``` +fastlane pull_request +``` +Performs tests and a static code analysis on the PR. Found issues are commented on the PR. +### test +``` +fastlane test +``` + + +---- + +This README.md is auto-generated and will be re-generated every time [fastlane](https://fastlane.tools) is run. +More information about fastlane can be found on [fastlane.tools](https://fastlane.tools). +The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools). diff --git a/fastlane/before_install.sh b/fastlane/before_install.sh new file mode 100755 index 00000000..c5b50370 --- /dev/null +++ b/fastlane/before_install.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +sudo gem install fastlane -v 2.19.1 +sudo gem install slather -v 2.3.0 +gem cleanup + +brew install swiftlint +brew install sonar-scanner \ No newline at end of file diff --git a/fastlane/run.sh b/fastlane/run.sh new file mode 100755 index 00000000..a43d0ffa --- /dev/null +++ b/fastlane/run.sh @@ -0,0 +1,9 @@ +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + if [ "$TRAVIS_SECURE_ENV_VARS" == "true" ]; then + FASTLANE_EXPLICIT_OPEN_SIMULATOR=2 fastlane pull_request_from_upstream; + else + FASTLANE_EXPLICIT_OPEN_SIMULATOR=2 fastlane pull_request_from_fork; + fi +else + FASTLANE_EXPLICIT_OPEN_SIMULATOR=2 fastlane integration; +fi \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..38599fa5 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,31 @@ +# reference: https://raw.githubusercontent.com/Backelite/sonar-swift/master/sonar-project.properties + +# Project identification +sonar.projectKey=de.tum.in.www.Tum-Campus-App +sonar.projectName=TUM Campus App + +#sonar.links.homepage=https://github.com/SonarSource/sq-com_example_standard-sqscanner-travis +sonar.links.ci=https://travis-ci.org/TCA-Team/iOS +sonar.links.scm=https://github.com/TCA-Team/iOS +sonar.links.issue=https://github.com/TCA-Team/iOS/issues + +sonar.host.url=https://sonarqube.com +# Credentials are stored in environment variables and get passed into the sonar-scanner command by Fastlane + +sonar.sources=TUM Campus App/ +sonar.tests=TUM Campus AppUnitTests/ +sonar.language=swift + +sonar.junit.reportsPath=fastlane/reports/ +sonar.junit.include=*.junit +#sonar.swift.lizard.report=reports/lizard-report.xml +sonar.swift.appScheme=TCA-CI +sonar.swift.coverage.reportPattern=fastlane/reports/cobertura.xml +sonar.flex.cobertura.reportPath=fastlane/reports/cobertura.xml +sonar.swift.swiftlint.report=fastlane/reports/swiftlint.txt + +# Github credentials are stored in environment variables and get passed into the GitHub Plugin by Fastlane +sonar.issuesReport.console.enable=true + +#see issues encountered by the C/C++ preprocessor +#sonar.verbose=true \ No newline at end of file