0
0
iOS Swiftmobile~5 mins

XCTest framework in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the XCTest framework used for in iOS development?
XCTest is used to write and run tests that check if your iOS app works correctly. It helps find bugs early by testing code automatically.
Click to reveal answer
beginner
How do you define a test case class in XCTest?
You create a class that inherits from XCTestCase. Inside, you write test methods that start with the word 'test'.
Click to reveal answer
intermediate
What is the purpose of the setUp() and tearDown() methods in XCTest?
setUp() runs before each test to prepare the environment. tearDown() runs after each test to clean up. They help keep tests independent.
Click to reveal answer
beginner
How do you check if two values are equal in an XCTest test method?
Use XCTAssertEqual(value1, value2) to verify that both values are the same. If not, the test fails.
Click to reveal answer
beginner
What happens when an assertion like XCTAssertTrue fails during a test?
The test is marked as failed but continues running. This shows that the code did not behave as expected.
Click to reveal answer
Which class should your test classes inherit from when using XCTest?
ANSObject
BUIViewController
CXCTestCase
DAppDelegate
What prefix must test method names start with in XCTest?
Atest
Bverify
Crun
Dcheck
What is the role of the tearDown() method in XCTest?
APrepare test data before each test
BClean up after each test
CRun all tests automatically
DDefine test cases
Which assertion checks if a condition is true in XCTest?
AXCTAssertTrue
BXCTAssertEqual
CXCTAssertFalse
DXCTFail
What happens if an assertion fails during a test?
ATest is marked as failed and stops
BTest is marked as passed
CTest is skipped
DTest continues running
Explain how to create and run a simple test case using XCTest in Swift.
Think about the class, method names, and how you check results.
You got /4 concepts.
    Describe the purpose of setUp() and tearDown() methods in XCTest and why they are important.
    Consider how tests stay independent and clean.
    You got /4 concepts.