Add a new screen
Add Tests
This commit is contained in:
22
StudyCK/StudyCKUITests/Info.plist
Normal file
22
StudyCK/StudyCKUITests/Info.plist
Normal file
@@ -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>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
74
StudyCK/StudyCKUITests/StudyCKUITests.swift
Normal file
74
StudyCK/StudyCKUITests/StudyCKUITests.swift
Normal file
@@ -0,0 +1,74 @@
|
||||
import XCTest
|
||||
@testable import StudyCK
|
||||
|
||||
class StudyCKUITests: XCTestCase {
|
||||
|
||||
var app: XCUIApplication! = nil
|
||||
|
||||
override func setUp() {
|
||||
super.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
|
||||
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
|
||||
app = XCUIApplication()
|
||||
app.launch()
|
||||
// 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.
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testEmptyUsernameAndPassword() {
|
||||
app.buttons["登入"].tap()
|
||||
let test = expectation(for: NSPredicate(format: "exists == 1"), evaluatedWith: app.alerts["錯誤"], handler: nil)
|
||||
wait(for: [test], timeout: 10)
|
||||
XCTAssert(app.alerts["錯誤"].staticTexts["帳號不存在"].exists)
|
||||
app.alerts["錯誤"].buttons["重試"].tap()
|
||||
}
|
||||
|
||||
func testEmptyUsername() {
|
||||
app.secureTextFields["passwordField"].tap()
|
||||
app.secureTextFields["passwordField"].typeText("aa")
|
||||
app.buttons["登入"].tap()
|
||||
let test = expectation(for: NSPredicate(format: "exists == 1"), evaluatedWith: app.alerts["錯誤"], handler: nil)
|
||||
wait(for: [test], timeout: 10)
|
||||
|
||||
XCTAssert(app.alerts["錯誤"].staticTexts["帳號不存在"].exists)
|
||||
}
|
||||
|
||||
func testEmptyPassword() {
|
||||
app.textFields["usernameField"].tap()
|
||||
app.textFields["usernameField"].typeText("ck1060535")
|
||||
app.buttons["登入"].tap()
|
||||
let test = expectation(for: NSPredicate(format: "exists == 1"), evaluatedWith: app.alerts["錯誤"], handler: nil)
|
||||
wait(for: [test], timeout: 10)
|
||||
XCTAssert(app.alerts["錯誤"].staticTexts["密碼錯誤,請再試一次"].exists)
|
||||
}
|
||||
|
||||
func testWrongPassword() {
|
||||
app.textFields["usernameField"].tap()
|
||||
app.textFields["usernameField"].typeText("ck1060535")
|
||||
app.secureTextFields["passwordField"].tap()
|
||||
app.secureTextFields["passwordField"].typeText("aa")
|
||||
app.buttons["登入"].tap()
|
||||
let test = expectation(for: NSPredicate(format: "exists == 1"), evaluatedWith: app.alerts["錯誤"], handler: nil)
|
||||
wait(for: [test], timeout: 10)
|
||||
XCTAssert(app.alerts["錯誤"].staticTexts["密碼錯誤,請再試一次"].exists)
|
||||
}
|
||||
|
||||
func testLogin() {
|
||||
app.textFields["usernameField"].tap()
|
||||
app.textFields["usernameField"].typeText("tUsername")
|
||||
app.secureTextFields["passwordField"].tap()
|
||||
app.secureTextFields["passwordField"].typeText("tPassword")
|
||||
app.buttons["登入"].tap()
|
||||
expectation(for: NSPredicate(format: "exists == 1"), evaluatedWith: app.navigationBars["choiceController"], handler: nil)
|
||||
waitForExpectations(timeout: 10, handler: nil)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user