Fill the blank
Fill the blank with the Swift Testing check.
import Testing
@Test("Total includes tax")
func totalIncludesTax() {
let cart = Cart(items: [Item(price: 25)], taxRate: 0.2)
____(cart.total == 30)
}Hint 1 of 1
Which macro checks without stopping the test?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A #expect
Correct. It records a failure with the values involved and keeps running.
Why not the others?
- B
XCTAssertTrue. XCTest assertions don't report properly inside Swift Testing tests. - C
#require. #require throws, so it needstryand is for preconditions that should stop the test. - D
assert. assert crashes in debug builds and does nothing in release; it isn't a test check.