swift-testcases is an two application designed to demonstrate test cases for a login page using XCTest and the Testing framework.
-
Swift-Login-Testing: The name implies that it showcases test cases for a login page using the Testing framework.
-
Swift-Login-XCTest: The name suggests that it highlights test cases for a login page using the XCTest framework.
-
Language: Swift
-
Xcode Version: 16.0 and later
-
Login UI.
-
Testcases for login page using XCTest and Testing framework.
Example of test case of Sign in button attached with action
func testSubmit_WhenCreated_HasSignInButtonAndAction() throws {
// Arrange
let signinButton: UIButton = try XCTUnwrap(loginVC.signInButton, "Signin button does not have a referencing outlet")
// Act
let signinButtonActions = try XCTUnwrap(signinButton.actions(forTarget: loginVC, forControlEvent: .touchUpInside), "Login button does not have any actions assigned to it")
// Assert
XCTAssertEqual(signinButton.titleLabel?.text, "Sign In", "Sign In button has Sign In Title")
XCTAssertEqual(signinButtonActions.count, 1)
XCTAssertEqual(signinButtonActions.first, "onSignInClick:", "There is no action with a name onSignInClick assigned to Signin button")
}
Example of test case of Sign in button attached with action
@Test func submitWhenCreatedHasSignInButtonAndAction() throws {
// arrange
let signInButton: UIButton? = loginVC.signInButton
// act
let signInButtonActions = signInButton?.actions(forTarget: loginVC, forControlEvent: .touchUpInside)
// expect
#expect(signInButton?.titleLabel?.text == "Sign In", "Sign In button has Sign In Title")
#expect(signInButtonActions?.count == 1, "Signin Button Actions Count Should Be 1")
#expect(signInButtonActions?.first == "onSignInClick:", "There is no action with a name onSignInClick assigned to Signin button")
}
Please feel free to create a pull request.
swift-testcases is written in Swift and is open source.