Skip to content
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

IMA-7642 #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// CPTBundleWithMultipleSuites.swift
// CPTBundleWithMultipleSuites
//
// Created by Rishab Sukumar on 8/13/19.
// Copyright © 2019 Rishab Sukumar. All rights reserved.
//

import XCTest

class CPTBundleWithMultipleSuites : XCTestCase {

override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false

// 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.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()

// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testLaunchPerformance() {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) {
XCUIApplication().launch()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// CPTNavigateTabs.swift
// CPTBundleWithMultipleSuites
//
// Created by Rishab Sukumar on 8/13/19.
// Copyright © 2019 Rishab Sukumar. All rights reserved.
//

import XCTest

class CPTNavigateTabs: XCTestCase {

let app = XCUIApplication()
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
app.launch()
let testsTab = self.app.radioButtons["Tests"]
testsTab.click()
// 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.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
self.app.terminate()
}

func testMessageTab() {
let testButton : XCUIElement = self.app.buttons["testButton"]
testButton.click()
let messageTab = self.app.radioButtons["Message"]
messageTab.click()
saveScreenshot(name: "CPTAutomationMessageTab")
}

func testMessageCountTab() {
let testButton : XCUIElement = self.app.buttons["testButton"]
testButton.click()
let messageCountTab = self.app.radioButtons["Message Counts"]
messageCountTab.click()
saveScreenshot(name: "CPTAutomationMessageCountTab")
}

func testRandomTab() {
let testButton : XCUIElement = self.app.buttons["testButton"]
testButton.click()
let randomTab = self.app.radioButtons["Random"]
randomTab.click()
saveScreenshot(name: "CPTAutomationRandomTab")
}

func saveScreenshot(name : String) {
let screenshot = self.app.screenshot()
let attachment : XCTAttachment = XCTAttachment(screenshot: screenshot)
attachment.lifetime = .keepAlways
attachment.name = name
add(attachment)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// CPTTitleChangeTests.swift
// CPTBundleWithMultipleSuites
//
// Created by Rishab Sukumar on 8/13/19.
// Copyright © 2019 Rishab Sukumar. All rights reserved.
//

import XCTest

class CPTTitleChangeTests: XCTestCase {

let app = XCUIApplication()
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
app.launch()
let testsTab = self.app.radioButtons["Tests"]
testsTab.click()
// 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.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
self.app.terminate()
}

func testEnterString() {
let testButton : XCUIElement = self.app.buttons["testButton"]
testButton.click()
let messageField : XCUIElement = self.app.textFields["messageField"]
messageField.click()
messageField.typeText("Hello")
saveScreenshot(name: "CPTAutomationTypedText")
}

func saveScreenshot(name : String) {
let screenshot = self.app.screenshot()
let attachment : XCTAttachment = XCTAttachment(screenshot: screenshot)
attachment.lifetime = .keepAlways
attachment.name = name
add(attachment)
}

func testChangeTitle() {
let testButton : XCUIElement = self.app.buttons["testButton"]
testButton.click()
let messageField : XCUIElement = self.app.textFields["messageField"]
messageField.click()
messageField.typeText("Changed Title")
saveScreenshot(name: "CPTAutomationTypedText")
let updateButton : XCUIElement = self.app.buttons["updateButton"]
updateButton.click()
saveScreenshot(name: "CPTAutomationUpdatedTitle")
}
}
22 changes: 22 additions & 0 deletions Sample-App/Sample-Test-App/CPTBundleWithMultipleSuites/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// CPTEmptyTestBundle.swift
// CPTEmptyTestBundle
//
// Created by Rishab Sukumar on 8/13/19.
// Copyright © 2019 Rishab Sukumar. All rights reserved.
//

import XCTest

class CPTEmptyTestBundle: XCTestCase {

override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false

// 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.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}


}
22 changes: 22 additions & 0 deletions Sample-App/Sample-Test-App/CPTEmptyTestBundle/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
24 changes: 24 additions & 0 deletions Sample-App/Sample-Test-App/CPTSingleBundleSingleTest.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"configurations" : [
{
"id" : "9B6CEFD8-4B31-401B-B272-C10B82683360",
"name" : "Configuration 1",
"options" : {

}
}
],
"defaultOptions" : {

},
"testTargets" : [
{
"target" : {
"containerPath" : "container:Sample-Test-App.xcodeproj",
"identifier" : "5443C23B230370C0009E7319",
"name" : "CPTTitleChangeTests"
}
}
],
"version" : 1
}
24 changes: 24 additions & 0 deletions Sample-App/Sample-Test-App/CPTTestPlanWithUnitTest.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"configurations" : [
{
"id" : "5DCB3576-8C28-460C-894A-2B3D6FCFD6BB",
"name" : "Configuration 1",
"options" : {

}
}
],
"defaultOptions" : {

},
"testTargets" : [
{
"target" : {
"containerPath" : "container:Sample-Test-App.xcodeproj",
"identifier" : "5443C26523047D57009E7319",
"name" : "CPTUnitTestBundle"
}
}
],
"version" : 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// CPTTitleChangeTests.swift
// CPTTitleChangeTests
//
// Created by Rishab Sukumar on 8/13/19.
// Copyright © 2019 Rishab Sukumar. All rights reserved.
//

import XCTest

class CPTTitleChangeTests: XCTestCase {

let app = XCUIApplication()
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
app.launch()
let testsTab = self.app.radioButtons["Tests"]
testsTab.click()

// 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.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
self.app.terminate()
}

func saveScreenshot(name : String) {
let screenshot = self.app.screenshot()
let attachment : XCTAttachment = XCTAttachment(screenshot: screenshot)
attachment.lifetime = .keepAlways
attachment.name = name
add(attachment)
}

func testChangeTitle() {
let testButton : XCUIElement = self.app.buttons["testButton"]
testButton.click()
let messageField : XCUIElement = self.app.textFields["messageField"]
messageField.click()
messageField.typeText("Changed Title")
saveScreenshot(name: "CPTAutomationTypedText")
let updateButton : XCUIElement = self.app.buttons["updateButton"]
updateButton.click()
saveScreenshot(name: "CPTAutomationUpdatedTitle")
}
}
22 changes: 22 additions & 0 deletions Sample-App/Sample-Test-App/CPTTitleChangeTests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// CPTTestChangeTitle.swift
// CPTUnitTestBundle
//
// Created by Rishab Sukumar on 8/14/19.
// Copyright © 2019 Rishab Sukumar. All rights reserved.
//

import XCTest
@testable import Sample_Test_App
class CPTTestChangeTitle: XCTestCase {

let app = firstViewController()
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
super.tearDown()
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testChangeTitle() {
app.message = "Test1"
app.isButtonClick(self)
XCTAssertEqual(app.label, app.message)
app.message = "Test2"
app.isButtonClick(self)
XCTAssertEqual(app.label, app.message)
}

}
Loading