Complete the code to declare a test case class in Swift.
import XCTest class [1]: XCTestCase { }
The test case class must inherit from XCTestCase. Naming it MyTestCase is a common convention.
Complete the code to write a test method that checks if 2 + 2 equals 4.
func testAddition() {
XCTAssertEqual([1], 4)
}The test checks if 2 + 2 equals 4. This is a simple assertion example.
Fix the error in the test method declaration to make it a valid test method in Swift.
func [1]() {
XCTAssertTrue(true)
}Test methods must start with test in lowercase to be recognized by XCTest.
Fill both blanks to create a test that fails if the value is not nil.
func testValueIsNil() {
let value: String? = nil
XCTAssert[1](value [2] nil)
}XCTAssertTrue checks if a value is nil. The comparison uses == nil to confirm the value is nil.
Fill all three blanks to write a test that verifies a function returns true for positive numbers.
func testIsPositive() {
let number = 5
let result = isPositive([1])
XCTAssert[2](result == [3])
}The function isPositive is called with number. The test asserts the result is true using XCTAssertTrue.