-1
IF UItest is running 
{
//execute this code
}
else
{
//execute this code

}

can anyone tell what should be the conditional statement here

  • 2
    Does this answer your question? [How do I access a preprocessor macro from code in Xcode using Swift?](https://stackoverflow.com/questions/53646397/how-do-i-access-a-preprocessor-macro-from-code-in-xcode-using-swift) – Laffen Oct 18 '21 at 06:09
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Oct 18 '21 at 08:26

1 Answers1

0

Method 1: pass args through test code

// In UI test file
class ProfileUI: XCTestCase {
    let app = XCUIApplication()

    override func setUpWithError() throws {
        app.launchArguments = ["-isUITestMode", "user_324234"]
        app.launch()
    }
}

Method 2: pass args through scheme

enter image description here

Check the args

if CommandLine.arguments.contains("-isUITestMode") {
    // running ui test
} else if CommandLine.arguments.contains("-isUnitTestMode") {
    // running unit tests
} else {
    // normal
}
ChanOnly123
  • 1,004
  • 10
  • 12