How to Swizzle Date (not NSDate) in Swift for XCUITest?

187 Views Asked by At

I have one scenario where I need to change value of Date in swift while doing XCUITest.

I mean if current date returns 2022/07/06 22:31, I just want it should use some different time while running UI test cases say 2022/07/06 24:31

Example:

let date = Date()
myLabel.text = date // 2022/07/06 22:31

While running UI test cases, if I swizzle Date and replace it with some other date by adding 2 hours.



So while executing UI test case, 
myLabel.text = date // 2022/07/06 24:31
0

There are 0 best solutions below