Skip to content

Written test cases for the login page in both XCTest and Testing framework.

Notifications You must be signed in to change notification settings

shahsaumil2001/swift-testcases

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

swift-testcases

swift-testcases is an two application designed to demonstrate test cases for a login page using XCTest and the Testing framework.

  1. Swift-Login-Testing: The name implies that it showcases test cases for a login page using the Testing framework.

  2. Swift-Login-XCTest: The name suggests that it highlights test cases for a login page using the XCTest framework.

Technology Stack

  • Language: Swift

  • Xcode Version: 16.0 and later

Key Features

  • Login UI.

  • Testcases for login page using XCTest and Testing framework.

Syntax of XCTest 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")
}
    

Syntax of Swift Testing Framework

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")
}
    

Comparison between XCTest & Testing framework

Screenshot 2024-12-04 at 7 27 42 PM

📫 Reach me for any questions/suggestion 👇:

LinkedInIcon

Please feel free to create a pull request.

License

swift-testcases is written in Swift and is open source.

About

Written test cases for the login page in both XCTest and Testing framework.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published