Thread
#multiplatform
    c

    curioustechizen

    2 years ago
    In a multiplatform module that has
    commonMain
    and
    iosMain
    , I want to create a
    iosTest
    folder that uses iOS-specific code for writing tests to be run on the simulator. I've looked around but I think all the info I find is out-dated. What's the latest on this?
    Kris Wong

    Kris Wong

    2 years ago
    if you have a target named ios, then you already have a source set named iosTest
    c

    curioustechizen

    2 years ago
    Hmm, I think the project I'm working on was customized to remove iosTest (maybe it wasn't needed then). I think I can simply create iosTest. But does it automatically have access to XCTest or XCUITest?
    Kris Wong

    Kris Wong

    2 years ago
    no, it does not. it uses kotlin.test
    c

    curioustechizen

    2 years ago
    okay. And is it possible to get access to XCTest in iosTest?
    Kris Wong

    Kris Wong

    2 years ago
    not that I am aware of
    you would need a test runner that supported that, i.e., Xcode
    c

    curioustechizen

    2 years ago
    My objective is: I have a multiplatform library and to test it I need the proper lifecycle classes (Activity in Android and ViewController on iOS). I want to keep the tests next to the library so that they run whenever there are changes to the library
    Kris Wong

    Kris Wong

    2 years ago
    you don't need XCUITest to use a view controller
    c

    curioustechizen

    2 years ago
    Ah! This is awesome. Thanks a bunch
    Wait .. are you saying I can write automated tests for a ViewController without XCUITest?
    Kris Wong

    Kris Wong

    2 years ago
    yes
    c

    curioustechizen

    2 years ago
    You can probably guess that my knowledge of iOS is very low 🙂 Can you drive a ViewController's lifecycle in a test by simply calling the appropriate method? For example, if I wanted to test that when
    viewDidLoad
    happens, then some dependency is called, then can I just instantiate a ViewController and call
    viewDidLoad
    on it in my test?
    Kris Wong

    Kris Wong

    2 years ago
    i believe you just create the view controller and call
    view
    c

    curioustechizen

    2 years ago
    Alright I'll research this. Thanks!